Based on the GCM documentation, you can set content_available to true .
(In iOS, this field is used to represent content available in the APNS payload. When a notification or message is sent, and this value is true, the inactive client application wakes up. In Android, data messages awaken the default application. In Chrome, it is not currently supported. )
content_available corresponds to Apple content-available , which you can find in this Apple Notification Service documentation .
In addition, you should use Download notifications to send a message to your iOS application so that it can display a banner when your application is in the background.
Here is an example HTTP request:
https://gcm-http.googleapis.com/gcm/send Content-Type:application/json Authorization:key=API_KEY { "to" : "REGISTRATION_TOKEN", "notification" : { "sound" : "default", "badge" : "1", "title" : "default", "body" : "Test", }, "content_available" : true, }
The Java library is just a sample, you can add other fields to it. For example, in the Message.java class, you can add two private variables, one of which is private final Boolean contentAvailable , the other is private final Map<String, String> notification .
You can try the HTTP request in your terminal by doing curl -i -H "Content-Type:application/json" -H "Authorization:key=API_KEY" -X POST -d '{"to":"REGISTRATION_TOKEN", "notificaiton":{"sound":"default", "badge":"1", "title": "default", "body":"test",},"content_available":true}' https://android.googleapis.com/gcm/send or try it in Postman .
Edited by:
If your application has been interrupted and you want push notifications to be displayed on your device, you can set a high priority in your HTTP request body (beware that setting your messages to a high priority contributes more to battery leakage than regular priority messages )
Example HTTP request:
{ "to" : "REGISTRATION_TOKEN", "notification" : { "sound" : "default", "badge" : "1", "title" : "default", "body" : "Test", }, "content_available" : true, "priority" : "normal", }