Start a new topic

Android push notif in system tray when app is in background <missing message content>

I'm trying to send push notifications from a custom endpoint code. I'm unable to show notification message in the system tray when the app is in background. It always shows "<missing message content>". Code as follows.


var push = modules.push;

  var collectionAccess = modules.collectionAccess;

  collectionAccess.collection('user').find({"username": request.params.username}, function (err, userColl) {

    if (err) {

      logger.error('Query failed: '+ err);

    } else {

      var androidPayload = {

          subject: "Booking request",

          message: "We are unable to service you due to unavailability of this model in your area",

         from: "Cars App"

      };

      userColl.forEach(function (user) {

        push.sendPayload(user, null, null, androidPayload);

      });

    }

  });


From what I have worked out, the json data being sent by the Push.sendPayload is being modified to the following, which Android is not recognizing


Sent by Kinvey:

{msg: "{"subject":"Booking request","message":"We are unable...","from":"Cars App"}", foreground: false}


If the following is sent using Postman, the system tray is able to show the message properly.

{

 "to": "<my_device_id>",

 "notification": {

   "title": "Booking requests",

   "body": "We are unable to..."

  }

}


How can I use the Push module to send a message that will show properly in system tray when the app is running in background?


Please ask for any info that I should have but haven't added here :)


Any update on this? Is there a bug logged? When will it be fixed?

Hi Santosh,

Could you please share the code with us where you are handling these Push notifications on client side. If you don't feel comfortable with sharing it here then please email it to me(abhijeet@kinvey.com). I will continue to look into this.

Regards,
Abhijeet 


This is the code. Just to clear things out (I could have understood them wrongly), I'm receiving the payload in the function and able to work with it in the app. But when the app is in the background, the push notif received does not show correctly in the android system tray.


 

pushPlugin.onMessageReceived(function callback(message, data) {
  // KINVEY WAY OF THINGS - Activate this code if binding notifs with Kinvey Custom endpoint
  var notifData = JSON.parse(data);
  var msg = JSON.parse(notifData.msg);
  dialogs.alert({
    title: msg.subject,
    message: msg.message
  });
});

 

Hello Santosh,


I wanted to let you know that Abhijeet is working this problem for you. He is trying to reproduce it in his environment. As soon as he has questions or suggestions, he will be back in touch with you via this Forum post.


Regards,


Billy Gee

Login or Signup to post a comment