Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send silent push to iOS via Google Cloud Messaging

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?

like image 308
MMiroslav Avatar asked Jun 03 '15 09:06

MMiroslav


2 Answers

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"}'
like image 73
TheWonderBird Avatar answered Nov 16 '22 00:11

TheWonderBird


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.

like image 45
Koh Avatar answered Nov 16 '22 00:11

Koh