Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase silent apns notification

Is there a way to send a silent APNS using google's firebase? It seems that if the app is in the background it will always show a notification to the user.

Thanks?

like image 688
roiberg Avatar asked Jun 01 '16 13:06

roiberg


People also ask

How do I turn on silent APN notifications?

There are two ways users can receive silent push notifications on Android. Users can long press on a notification to get an option to display notifications silently. Users can also enable silent notifications by heading to Settings > App & Notifications > Search for app and choose> Notifications, and turn it off.

Will iOS awake my app when I receive silent push notification?

Yes. It will. When you click on that. Yeah its ok but being push notification is silent,you are not able to view any alert and cant click.

What is silent push notification?

They arrive on the mobile device and sit in the notification tray until read or dismissed. Users can choose to mute their notifications and receive silent push notifications instead of being alerted to every new push that arrives. They can activate this on iOS or Android from their individual settings pages.


1 Answers

You can send silent APNS messages using the FCM server API https://firebase.google.com/docs/cloud-messaging/http-server-ref

In particular you need to use:

  • The data field:

This parameter specifies the custom key-value pairs of the message's payload.

For example, with data:{"score":"3x1"}:

On iOS, if the message is sent via APNS, it represents the custom data fields. If it is sent via FCM connection server, it would be represented as key value dictionary in AppDelegate application:didReceiveRemoteNotification:.

The key should not be a reserved word ("from" or any word starting with "google" or "gcm"). Do not use any of the words defined in this table (such as collapse_key).

Values in string types are recommended. You have to convert values in objects or other non-string data types (e.g., integers or booleans) to string

  • The content_available field:

On iOS, use this field to represent content-available in the APNS payload. When a notification or message is sent and this is set to true, an inactive client app is awoken. On Android, data messages wake the app by default. On Chrome, currently not supported.

Full documentation: https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream-http-messages-json

like image 121
Diego Giorgini Avatar answered Oct 01 '22 16:10

Diego Giorgini