iOS 自定义声音通知位置

iOS Custom Sound Notifications Location

我对将我的 iOS 应用程序的声音文件放在哪里有一些疑问。在 android 上,我不得不将它们放在 platform/android/res/raw 文件夹中,它起作用了。在 iOS 上,我在 Xcode 上打开了我的 project.xcodeproj,但是当我将我的 .mp3 文件拖到 Xcode 项目中时,清理、构建和 运行我的 iPad 上的项目,我无法使用自定义声音,我有默认声音。

我的 PushInit:

var push = PushNotification.init({
            "android": {
                "senderID": "xxxxx",
                "alert": "true",
                "badge": "true",
                "sound": "true"
            },
            "ios": {
                "gcmSandbox": "true",
                "senderID": "xxxxx",
                "alert": "true",
                "badge": "true",
                "sound": "true"
            },

这是我的工作负载:

{
"registration_ids":["xxxxx"],
"notification":
   {
    "title":"Message",
    "body":"Nouvelle intervention",
    "vibrate":1,
    "sound":"sirene"
   },
"data":   
   {
    "uid":"5811e9c946755",
    "quittance":0
   },
"priority":"high",
"content_available":true
}

声音 "sirene" 是一个 .caf 文件。

我必须将声音文件放在哪里?我只是将它们拖到项目中,然后添加到目标中。

如果我点击我的声音,路径是:

它自动放在这里

您应该将它们拖到项目的 Resources 文件夹中,方法是将它们拖到 xcode 中。如果您使用的是 iOS 10,则存在一个错误,可能需要您重新启动 phone 才能播放自定义声音。