Silent notifications works only when app in foreground

Hi,

we need to use silent notifications in our app. Seems it works only when the app is in foreground or in debugging.

When the app goes background the silent notification doesn't wake the app anymore.

I added the headers to the request:

"apns-id": Guid.NewGuid().ToString("D")
"apns-push-type": "background"
"apns-priority":"5"
"apns-topic":{AppBundleID}

I used the payload from the documentation:

{"aps" : { "content-available" : 1 } , "acme1" : "bar" }


I tried to send the "alert" aswell in the playload, i tried everything what i found on forums. Seems nothing works.

When i am debugging the app, i get the silent noifications and everything works as expected.

When i unplug the phone, the silent notification does not wake the app anymore.

I followed every steps as it stated in the documentation.

Everything should be set properly as it worked on IOS12 but stopped working since IOS13.

Replies

The documentation for the push payload explicitly state that sending a "content-available" message with badge, alert, or sound specified is invalid. Can you share what push provider you are using? I'd check the response from APNs request to send if you have access to such information.


A few things to check:

1. Ensure background app refresh is enabled for the system, and subsequently, the application.

2. Ensure low-data-mode is not configured for the connected network.

3. Ensure low-power mode is not enabled (which disables background fetch)

We have the same issue on my device with iOS 13.4.1. And we don't get that worked in background even if debugging.

I've checked the three things above, background app refresh was enabled, low data mode was off and low power mode was disabled.
I'm encountering this issue today using iOS 14 beta 7. Did either of you ever find a solution?
The issue you are seeing is expected, and it is due to content-available (aka "background" or "silent") push notifications being throttled when being delivered to apps that are in the background.

Background push notifications are never guaranteed to be delivered to the app every single time. This is not new to iOS 13 or iOS 14.

The WWDC 2020 video "Background execution demystified" (https://developer.apple.com/videos/play/wwdc2020/10063/) explains the factors that effect background runtime.


I’ve got 2 devices with both same iOS version (14.2), the same app and the same configuration (low power mode and low data mode disabled, background refresh enabled) and I have 2 different behaviours :
  • One (called A) receive silent notification all the time

  • The other (called B) receive silent notification ONLY when app is in foreground mode

I’ve got other devices on other iOS versions (iOS 12.4.9 and iOS 13.7), I always receive silent notification all the time.

So I use Wireshark software to analyse network messages between the B device and my router. When my app is in foreground, I saw silent notification like expected coming from Apple server (17.57.146.4).
When I leave my app, I saw my device communicating with Apple server, next I send silent notification but there is nothing, Apple server doesn’t send silent notification. I've got the same behaviour when I lock the device.

I use the same test for the A device, I saw device communicating with Apple server even when my app is in background.

I think there is a iOS 14.x bug because I don't have any problem on other iOS version below 14.
Like Gualtier Malde replied. The issue you are seeing with silent/background notifications is expected. And it has been going to that "muted" direction from IOS 11 onwards.. (or earlier).

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

The system treats background notifications as low priority: you can use them to refresh your app’s content, but the system doesn’t guarantee their delivery. In addition, the system may throttle the delivery of background notifications if the total number becomes excessive. The number of background notifications allowed by the system depends on current conditions, but don’t try to send more than two or three per hour.