简体   繁体   中英

How to implement app behavior when user turn off notification in device setting for iOS using Firebase FCM swizzling turned on?

If I enable FCM swizzling in iOS, I found that the FCM token is still there even when user turns off the device notification setting for my app(probably saved in app data).

It seems not logical to manage this setting anymore inside the app since FCM takes care of that part for me.

I have 2 questions:

  1. Do I need to create a Notification setting switch inside my app so that user can turn on or turn off the notification?
  2. If I need to do #1, how do I call the FCM registration manually? I know that this api [ FIRApp configure ] will do everything automatically.

I think following pointers should help you answer the question.

  1. Generically (Regardless of which SDK you use), generating and maintaining deviceToken is completely decoupled from the permissions prompt and the response given to that prompt. There are use cases like silent pushes which can be used to send pushes to the device without even asking the user for permissions (well, these pushes invoke your app for data refresh, but can not show anything on UI)

  2. Even when we prompt the user for permissions, denying the permission does not invalidate the token that has been generated already. The UI based pushes(Alert, Badge, Sound) sent in this case, will still land on the device but iOS will not render those notifications after checking the user's permissions.

So based on above data points, to answer your question,

Do I need to create a Notification setting switch inside my app so that user can turn on or turn off the notification?

Yes, its certainly a good idea to have it so, but note that after the initial permissions prompt the same dialog wont be shown again, hence its better to redirect the user to settings of your app where he can re-enable the notification permissions, refer to this thread on implementing the same.

If I need to do #1, how do I call the FCM registration manually? I know that this api [FIRApp configure] will do everything automatically.

I don't have experience in using Firebase directly, but, mostly you don't need to tell anything to Firebase, because it already has a token and it can sent pushes to this device anytime, the next push that comes after user modifies the setting will automatically show up according to latest preferences of the user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM