using content-available:1 in 'non-silent' pushes

In WWDC 720 ("What's New in Notifications"), the speaker Michele Campeotto talks about how silent notifications (where "content-available:1" is in the payload) are delivered on a "best effort" basis, using a number of factors: "It's going to use different signals from the device and from the user behavior, like power or the time of day to decide when it is a good time to deliver the notification and launch your app."


He drew a distinction between this behavior and (non-silent) "user notifications", where, presumably, the push message is generally shown to the user regardless of time of day or battery level.


But what is the expected behavior when a push has both an alert message (so is not "silent") but also has "content-available:1" (and so should wake up the app)?


In this situation, does the OS use the same discretion in waking the app that it would in a truly silent push? And does the addition of "content-available:1" have an effect on the display rate of the push message itself?


We've been sending pushes with both message string and the silent flag, and we suspect that some portion of the apps are receiving the notification in the UI but not being woken up. And we also want to make sure that the presence of the flag is not decreasing the number of apps that get the alert.

Replies

I have exactly the same question. Additionally, in iOS 10 in particular, if the app is woken up, you don't get a second callback to didReceiveRemoteNotification upon touching the notification from notification center

You shouldn't be sending a silent notification (content-available:1) with an alert message. You won't get consistent behavior and most likely the notification won't be displayed.


Per https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/TheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH107-SW6


Configuring a Silent Notification

The

aps
dictionary can also contain the
content-available
property. The
content-available
property with a value of
1
lets the remote notification act as a silent notification. When a silent notification arrives, iOS wakes up your app in the background so that you can get new data from your server or do background information processing. Users aren’t told about the new or changed information that results from a silent notification, but they can find out about it the next time they open your app.

For a silent notification, take care to ensure there is no

alert
,
sound
, or
badge
payload in the
aps
dictionary. If you don’t follow this guidance, the incorrectly-configured notification might be throttled and not delivered to the app in the background, and instead of being silent is displayed to the user.


Hope this helps,

DT

This is a very old thread, but in case anyone stumbles on it, I wanted to point out that this advice from Apple has changed since davidtruong included the above link (which no longer works). Now, Apple says combining alerts and content-available is OK:


To support a background update notification, make sure that the payload’s

aps
dictionary includes the
content-available
key with a value of
1
. If there are user-visible updates that go along with the background update, you can set the
alert
,
sound
, or
badge
keys in the
aps
dictionary, as appropriate.


https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html

Thanks for the update @petere.

It is worth noting that the current documentation now indicates (again) not to mix content-available with user-facing items such as alert


https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_updates_to_your_app_silently?language=objc

It is worth noting that the current documentation now indicates (again) not to mix content-available with user-facing items such as alert https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_updates_to_your_app_silently?language=objc

I can't find anything like that in the docs right now. Were there any updates to it? Are there any drawbacks from adding content-available and alert at the same time in notifications?