简体   繁体   中英

Android push notification from Bluemix

I'm trying to write Android mobile application that interacts with Bluemix push service.

Using Bluemix node js backend I generate my push notification and broadcast it to all my registered devices.

The push notification works great but when I try to provide Additional Payload, I don't get it at the mobile side while handling the

push event. The IBMSimplePushNotification object has payload member but it's empty.

My code looks like

broadcastNotification(function(pushMessage){
  // Push Notification content
  var message = {
    alert :”Hello",
    url : "https://www.bluemix.net"
  };

  //Custom payload is passed on the options parameter
  var settings = {
    gcm : {
        //Custom Payload to deliver to Android devices
        payload : { "text" : "Hello to Android devices" }
    }
  }

   push.sendNotificationByPlatform(message, ["G"], settings).then(function(response){
     console.log('The message was sent');
   },function(err){
    console.log('Error:'+err);
   });

Any details on how to make it working will be appreciated

Looks like your problem is due to the "text" property containing quotes. Try removing the quotations around "text" and try again, like so:

  //Custom payload is passed on the options parameter
  var settings = {
    gcm : {
        //Custom Payload to deliver to Android devices
        payload : { text : "Hello to Android devices" }
    }
  }

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