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.