How to send silent push notification to iOS application over GCM?
Silent push is notification that will not appear in notification center, but awake application to do some action in background. Google introduce new features in new GCM with possibility to send push messages to Android, Chrome and iOS.
Any idea, how to do this?
Use the content_available
(not content-available
) attribute like this:
curl -X POST --header "Content-Type:application/json" --header "Authorization:key=AIzaXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "https://android.googleapis.com/gcm/send" --data-ascii '{"data":{"xxx":"yyy"},"content_available":true,"to":"XXXXXXXXXX:YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY-ZZZZZZZZZZZZZZZZZZZZ"}'
From your server, you'll need to add the content-available
property with a value of 1 to your aps
dictionary.
You'll need to provide support for these silent notifications by adding remote-notification
to UIBackgroundModes
in your Info.plist file. More details here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With