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.

4

2 回答 2

2

我刚刚在最新版本的 Android Push SDK上测试了带声音的推送通知,并让它在我的 Android 手机上运行。

这是初始化我的应用程序:

这是我的声音文件: 在此处输入图像描述

这是我的要求: 在此处输入图像描述

于 2016-05-27T17:43:53.690 回答
0

几个小时前,发布了 Bluemix android push sdk 的 2.0.1 版以支持通知声音。

请记住,您需要将声音文件保存在res/raw目录中,然后您将能够像您提到的那样使用记录在案的有效负载:

"settings":{
     "gcm":{
     "sound":"notification.wav",
  }
 }

为延迟/混乱道歉。

于 2016-05-27T14:36:58.640 回答