IOS9 Push Battery Saver Mode - didReceiveRemoteNot

2020-04-29 16:31发布

问题:

On IOS9 if an iPhone is in battery save mode, the callback

application:didReceiveRemoteNotification:fetchCompletionHandler: 

is not called. Instead I get the following warning in the console

High Priority Push: com.your-company.app - Battery Saver Mode Enabled

When using PushKit it does seem to work.

Does anybody else experience this behaviour?

Any other workarounds?

回答1:

I believe, unfortunately, that this is the intended behavior. The documentation about push notifications constantly hedges their reliability. E.g.:

https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html

Important: Delivery of notifications is a “best effort”, not guaranteed. It is not intended to deliver data to your app, only to notify the user that there is new data available

There are a lot of conditions under which notifications won't be delivered or delivery will be delayed, and sometimes Apple will coalesce multiple notifications and only deliver the last one.

PushKit is a more reliable replacement for applications that want VOIP functionality, where using a notification to ring the user for a call needs better reliability. That's why it's still working in battery-save mode.

In terms of workarounds, it really depends what you're trying to accomplish. One possibility is you can schedule local notifications while your app is running, and those will be more reliable than the standard remote ones.