IBM Worklight 5.0.5 - Play custom sound on push notification

拟墨画扇 提交于 2019-12-02 16:13:19

问题


When I use

WL.Server.notifyAllDevices(userSubscription, {
        badge: 1,
        sound: "notification.wav",
        activateButtonLabel: "ClickMe",
        alert: notificationText,
        payload: {
            foo : 'bar'
        }
    });

to push a notification in IBM Worklight 5.0.5 on Android, it does not seem to be possible to use the custom sound option. No matter where I put the sound file, Worklight does not find it. According to the client traces, it does not even search for the file. Has anybody ever tried this successfully?


回答1:


To use a custom notification sound:

  1. If the folder does not exist already, add a folder named raw under the existing native\res folder in yourProject\apps\yourApp\android\native
  2. Place the sound file in the raw folder

When sending a notification it should now play your custom sound file.

You can also place the sound file in a raw folder under yourProject\apps\yourApp\android\nativeResources\res; this will make sure the file will be copied to your generated Android project upon build, in case you have deleted the native folder for whichever reason.



来源:https://stackoverflow.com/questions/16187608/ibm-worklight-5-0-5-play-custom-sound-on-push-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!