Bluemix Android 推送通知无法实现自定义声音通知
Bluemix Android Push Notification unable to implement custom sound notification
我正在尝试使用移动优先服务启动器 (MFSS) and/or 移动应用程序构建器在 Android 中实现 Bluemix 推送通知自定义声音。目前我可以向设备发送简单的推送通知并且运行良好。
当我想播放通知的声音时,问题就来了。
对于 MFSS,我正在尝试使用此代码:
MFPPushNotificationListener notificationListener = new MFPPushNotificationListener() {
@Override
public void onReceive(final MFPSimplePushNotification message)
Log.e("message arrives", message.toString());
NotificationManager notif = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification noty = new Notification.Builder(getApplicationContext())
.setTicker("Entrando al area de ROPA")
.setSmallIcon(R.drawable.ic_cast_dark)
.setWhen(System.currentTimeMillis())
.setContentText("Hello World")
.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notification))
.setContentInfo("Set ContextInfo")
.setContentTitle("Set title")
.setContentInfo(message.getAlert().toString())
.build();
PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0);
notif.notify(0, noty);
}
};
另一方面,我也在尝试将 IMF 推送服务 REST API 与此有效负载一起使用,消息到达但不播放声音::
{
"message": {
"alert": "mensaje"
},
"settings": {
"gcm": {
"payload": {
"sound": "notification.wav"
}
}
}
}
最后从推送通知仪表板我使用了文档有效负载,消息也到达但不播放声音:
"settings":{
"gcm":{
"sound":"notification.wav",
}
}
注意:我创建了原始文件夹以保存 notification.wav 文件,我还实现了一个按钮点击侦听器以测试声音文件并且运行良好,声音清晰.
任何帮助将不胜感激。
几个小时前,Bluemix android 推送 sdk 2.0.1 版本发布,支持通知声音。
请记住,您需要将声音文件保存在 res/raw
目录中,然后您就可以像您提到的那样使用记录的有效载荷:
"settings":{
"gcm":{
"sound":"notification.wav",
}
}
对delay/confusion表示歉意。
我刚刚在 latest version of the Android Push SDK 上测试了带声音的推送通知,并让它与我的 Android phone.
一起工作
这里正在初始化我的应用程序:
这是我的声音文件:
这是我的请求:
我正在尝试使用移动优先服务启动器 (MFSS) and/or 移动应用程序构建器在 Android 中实现 Bluemix 推送通知自定义声音。目前我可以向设备发送简单的推送通知并且运行良好。
当我想播放通知的声音时,问题就来了。
对于 MFSS,我正在尝试使用此代码:
MFPPushNotificationListener notificationListener = new MFPPushNotificationListener() {
@Override
public void onReceive(final MFPSimplePushNotification message)
Log.e("message arrives", message.toString());
NotificationManager notif = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification noty = new Notification.Builder(getApplicationContext())
.setTicker("Entrando al area de ROPA")
.setSmallIcon(R.drawable.ic_cast_dark)
.setWhen(System.currentTimeMillis())
.setContentText("Hello World")
.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.notification))
.setContentInfo("Set ContextInfo")
.setContentTitle("Set title")
.setContentInfo(message.getAlert().toString())
.build();
PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0);
notif.notify(0, noty);
}
};
另一方面,我也在尝试将 IMF 推送服务 REST API 与此有效负载一起使用,消息到达但不播放声音::
{
"message": {
"alert": "mensaje"
},
"settings": {
"gcm": {
"payload": {
"sound": "notification.wav"
}
}
}
}
最后从推送通知仪表板我使用了文档有效负载,消息也到达但不播放声音:
"settings":{
"gcm":{
"sound":"notification.wav",
}
}
注意:我创建了原始文件夹以保存 notification.wav 文件,我还实现了一个按钮点击侦听器以测试声音文件并且运行良好,声音清晰.
任何帮助将不胜感激。
几个小时前,Bluemix android 推送 sdk 2.0.1 版本发布,支持通知声音。
请记住,您需要将声音文件保存在 res/raw
目录中,然后您就可以像您提到的那样使用记录的有效载荷:
"settings":{
"gcm":{
"sound":"notification.wav",
}
}
对delay/confusion表示歉意。
我刚刚在 latest version of the Android Push SDK 上测试了带声音的推送通知,并让它与我的 Android phone.
一起工作这里正在初始化我的应用程序:
这是我的声音文件:
这是我的请求: