简体   繁体   中英

Sending Push Notifications with Parse Server Cloud Code using content-available not working

I am trying this approach to send push notifications from cloud code using Parse Server push adapter. The notifications is delivered successfully but the problem is how to use the 'content-available' flag. I'm not sure if i am using the flag the right way because the app is not being awaking when the notifications arrives as it should be.

This is the code:

Parse.Push.send({
   where: query,
    data: {
      alert: 'One more test 1',
      badge: 1,
      sound: 'default',
      content_available: 1
   }

}, { useMasterKey: true });

Again, the notifications arrives but the 'content-available' flag is not working. is anyone using this approach to send push notifications? Where should i put the 'content-available'?

Thank you all!

Well i got it! It's easier than i thought.

This would be the correct code:

Parse.Push.send({
    where: query,
    data: {
        alert: 'One more test 1',
        badge: 1,
        sound: 'default',
        objectId: user.id,
        'content-available': 1

    }

}, { useMasterKey: true });

The 'content-available' flag should be separated using dash ("-") and the entire phrase between quotes.

And that's it! Hope this could help someone struggling with this like i was.

Have a great code!

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