3

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.

Dave Cariello
  • 505
  • 6
  • 12

2 Answers2

2

I just tested Push notifications with sound on the latest version of the Android Push SDK, and got it working with my Android phone.

Here is initializing my application:

Here is my sound file: enter image description here

Here was my request: enter image description here

joe
  • 2,468
  • 2
  • 12
  • 19
  • Thanks for your response, I see that the new version 2.0.1 of push notification now works well using the push message dashboard. However my app use NODE-RED inspired in this tutorial: https://www.ibm.com/developerworks/library/wa-nodered-push-app/ In order to send push notification with a custom payload and I noticed that, the push message for some reason not always arrives to the devices, also I tried using the IMF Push Service REST API with the same result. https://mobile.ng.bluemix.net/imfpushrestapidocs/#!/messages/post_apps_applicationId_messages Regards, – user3368141 May 29 '16 at 01:15
  • Are you using an emulator or a real device? – joe May 31 '16 at 15:40
  • I'm using a real device (Huawei Ascend) – user3368141 Jun 01 '16 at 20:18
  • 1
    Could you create a new question with your new issue? (That way others can find out how to solve the problem if they encounter the same issue.) – joe Jun 01 '16 at 21:18
0

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.

Dave Cariello
  • 505
  • 6
  • 12