Bluemix Android Push Notification无法实现定制声音通知 [英] Bluemix Android Push Notification unable to implement custom sound notification

查看:117
本文介绍了Bluemix Android Push Notification无法实现定制声音通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Mobile First Services Starter(MFSS)和/或Mobile App Builder在Android中实现Bluemix Push Notification定制声音.目前,我可以向设备发送简单的推送通知,并且效果很好.

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.

对于MFSS,我正在尝试使用以下代码:

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);
    }
};

另一方面,我也尝试使用带有此有效负载的IMF推送服务REST API,消息到达但不播放声音:

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",
  }
 }

注意:我创建了原始文件夹以保存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.

任何帮助将不胜感激.

推荐答案

我刚刚在

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:

这是我的要求:

这篇关于Bluemix Android Push Notification无法实现定制声音通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆