Home > Blockchain >  iOS Notification Behavior when setting is OFF in device level
iOS Notification Behavior when setting is OFF in device level

Time:10-08

What is the expected behaviour of userNotificationCenter:willPresentNotification:withCompletionHandler: when the notification setting for an app is turned OFF in device level? I always assumed no callback will be called if setting is OFF but I am observing in my app that this callback is hitting the breakpoint even when device setting is OFF. Apple doc does not mention anything on the expected behaviour so wondering if anyone here knows what is expected or if this is an iOS bug.

Thanks!

CodePudding user response:

It's expected behavior and it is what you should expect. Let's tease it apart like this.

  • The user has said they do not want to see any evidence of notifications (alerts, banners, sounds, badges). But that does not mean that no notifications exist — the user has no ability to reach into the system and switch off the user notification center itself! So the notification center is still operative, and the notification, qua signal, still has the ability to arrive.

  • Very well, so indeed the user is not going see any alerts, banners, sounds, or badges. What's happening is merely that the notification qua signal has arrived, as we agreed in the previous point. And your app happens to be frontmost, and is thus in a position to hear about the fact that the notification signal arrived.

    And why shouldn't your app hear about this? Your app is not going to violate the user's wishes by presenting any notification alerts, banners, etc.; it cannot do so in any case. But it can still respond to the notification. There is no reason why the user should be permitted to reach into your app and lame it by preventing news of its own notifications from reaching it, any more than the user should be permitted to crush the operation of the user notification center.

  • Related