I'm trying to implement Bluemix Push Notification custom sound in Android with Mobile First Services Starter (MFSS) and/or Mobile App Builder. At the moment I can send simple push notifications to devices and works well.
The problem comes when I want to play a sound for notification.
With MFSS I'm trying using this code:
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);
}
};
On the other side also I'm trying using the IMF Push Service REST API with this payload the messages arrives but doesn't play the sound::
{
"message": {
"alert": "mensaje"
},
"settings": {
"gcm": {
"payload": {
"sound": "notification.wav"
}
}
}
}
Finally from the push notification dashboard I'm using the documentation payload, also the messages arrives but doesn't play the sound:
"settings":{
"gcm":{
"sound":"notification.wav",
}
}
Note: I'm created the raw folder in order to save the notification.wav file, also I'm implementing a button click listener in order to test the sound file and works well, the sound it's clear.
Any help will be appreciated.
I just tested Push notifications with sound on the latest version of the Android Push SDK , and got it working with my Android phone.
As of a few hours ago, version 2.0.1 of the Bluemix android push sdk was published to support notification sound.
Keep in mind, you will need to save your sound file in the res/raw
directory and then you will be able use the documented payload like you mention:
"settings":{
"gcm":{
"sound":"notification.wav",
}
}
Apologies for the delay/confusion.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.