问题
In my settings tabbar:
- I have a feature specific switch which can be turned OFF or ON based on API response.
- From website only admin is authorized to turn ON/OFF.
- I can make /user API call everytime on settings tap to check the current settings for the user but there are couple of disadvantage like if user is already on setting then it will not update the UI and calling api everytime on settings tap doesn't sounds a perfect solution.
I think better solution is to send a silent push notification which i can use to make the API call to update the settings UI whenever needed.
But if user has disabled the push notification will I still receive silent push ? What is the recommended approach to handle such situations ?
回答1:
Short answer, yes
The exciting new opportunity for app developers in iOS 8 is that Apple will now deliver “silent” pushes even if the user has opted out of notifications. Also, “silent push” is no longer just for Newsstand apps. Every app can take advantage of this ability to refresh content in the background, creating the most up-to-date, responsive experience possible, the moment the user opens the app.
Although...
Users still have the ability to switch off your app’s ability to process a “silent push” by means of the “Background App Refresh” control. Even though Apple Push Notification service (APNs) will deliver a push marked “content-available” to your phone, the OS will not wake up your app to receive it, effectively dropping it on the floor. However, opting out of “Background App Refresh” is a lesser-known capability not directly associated with Notifications. You don’t access this preference in your Notifications Settings--it’s located under General > Background App Refresh screen.
Keep this in mind when building your application.
Source: https://www.urbanairship.com/blog/watch-list-ios-8-opt-in-changes
回答2:
This matrix might help. At left hand side, it shows if "didReceiveRemoteNotification: " method will get called or not. Other two columns is related to setting app. Settings -> YourApp. If yourApp supports Notifications and background app refresh. Look into matrix to check when you app will receive silent push.
回答3:
Other answers are good. But they are not official answers.
The official answer is in What's New in Notifications WWDC 2015 video:
Silent notifications are enabled by default. The user does not need to approve your -- does not give permission to your app to use them, and you can just start using them without asking the user for permission. But silent notifications are the mechanism behind background app refresh. At any point you know that the user can go in settings and disable them. So you can't depend on them always being available. You don't know if the user the turn them off, and you are not getting a notification anymore. This also means that silent notifications are delivered with the best effort. That means that when the notification arrives on the user's device, the system is going to make some choices.
For more see this image and this answer
来源:https://stackoverflow.com/questions/30644343/is-silent-remote-notifications-possible-if-user-has-disabled-push-for-the-app