简体   繁体   中英

Worklight 6.1 - No Sound When Android Push Notification Arrives

i am having troubles with Push Notifications on Android devices (tested on 2.2.3 and 4.x). On IOS, the app works just fine, playing the default notification sound, as it should be. This is the code i am using to send notifications:

function submitNotification(userId, notificationText){
    var userSubscription = WL.Server.getUserNotificationSubscription('PushAdapter.PushEventSource', userId);


if (userSubscription==null){
    return { result: "No subscription found for user :: " + userId };
}

var badgeDigit = 0;

var notification = WL.Server.createDefaultNotification(notificationText, badgeDigit, {custom:"data"});

WL.Logger.debug("submitNotification >> userId :: " + userId + ", text :: " + notificationText);

WL.Server.notifyAllDevices(userSubscription, notification);

return { 
    result: "Notification sent to user :: " + userId 
};
}

I also tried to use a custom sound; same result: no sound on android.

You do not explain how you've tried to set a custom sound, it'd be nice if you do mention that.

In the meanwhile, see the following questions on the same subject (nothing has changed in this department, so the general steps are still true):

If it does not exist, create the folder titled "raw" inside the native\\res folder. Place your custom sound file there. Make sure to define it in code per the instructions in the 1st question above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM