使用自定义声音将 GCM 推送通知发送到 android
Send GCM Push Notification to android with custom sound
我正在使用以下参数选项从 php 服务器向 Android 应用程序(使用混合 php 通过 cordova 构建)发送 GCM 推送通知:
'message' => $message,
'image' => "www/icon/icon2.png",
'title' => $title,
'vibrate' => 1,
'priority' => 1,
'visibility'=> 1,
'foreground'=> true,
'no-cache' => 1,
'force-start' => 1,
'sound' => "res/raw/notify.mp3"
"notify.mp3" 存在于 app (apk) 的 res/raw 目录中。
通知成功到达应用程序,但指定的声音没有响起,只是振动。
我试过以下但 none 成功了:
'res/raw/notify.mp3'
'notify.mp3'
'android.resource:res/raw/notify.mp3'
'android.resource://R.raw.notify.mp3'
我搜索了很多,但无法找到 运行 自定义声音通知的解决方案。
有人可以帮忙吗?
不需要指定声音的文件夹:
'sound' => "notify.mp3"
无需指定位于 res/raw 文件夹下的文件的扩展名。我只是将 "notify.mp3" 放入 res/raw 文件夹并修改代码如下:
'sound' => "notify"
对我有用。
谢谢 :)
我正在使用以下参数选项从 php 服务器向 Android 应用程序(使用混合 php 通过 cordova 构建)发送 GCM 推送通知:
'message' => $message,
'image' => "www/icon/icon2.png",
'title' => $title,
'vibrate' => 1,
'priority' => 1,
'visibility'=> 1,
'foreground'=> true,
'no-cache' => 1,
'force-start' => 1,
'sound' => "res/raw/notify.mp3"
"notify.mp3" 存在于 app (apk) 的 res/raw 目录中。
通知成功到达应用程序,但指定的声音没有响起,只是振动。
我试过以下但 none 成功了:
'res/raw/notify.mp3' 'notify.mp3' 'android.resource:res/raw/notify.mp3' 'android.resource://R.raw.notify.mp3'
我搜索了很多,但无法找到 运行 自定义声音通知的解决方案。
有人可以帮忙吗?
不需要指定声音的文件夹:
'sound' => "notify.mp3"
无需指定位于 res/raw 文件夹下的文件的扩展名。我只是将 "notify.mp3" 放入 res/raw 文件夹并修改代码如下:
'sound' => "notify"
对我有用。
谢谢 :)