-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ios): add forceRegister option #337
base: master
Are you sure you want to change the base?
Conversation
On iOS, notification permissions only control *user-facing* notifications. Silent/invisible notifications can be received and handled in the background even when the user denies notification permissions. When forceRegister is true, registerForRemoteNotifications will be called on init even if requestAuthorizationWithOptions comes back with granted=FALSE. | `ios.forceRegister` | `boolean` | `false` | Optional. If `true` the app will register for remote notifications, even if the user has denied notification permissions. On iOS, notification permissions only control *user-facing* notifications – background pushes can still be received. |
What if the I'm trying to determine if there are viable use cases where an app developer might prefer not to support background notifications by default. In the current setup, only users who accept disruptive permissions (e.g., sounds, badges, alerts) can receive normal and background notifications. However, since background notifications can be used to update the app in the background and does not require permissions, why restrict this functionality based on the denial of disruptive permissions? |
I can't think of any cases but I thought it best not to introduce any breaking changes, at least not without a discussion first. Perhaps the strongest argument for keeping this behind a flag is that it represents a departure from Android. How important is it for this plugin to behave the same on both platforms by default? |
Ideally, both platforms should behave the same by default. I think keeping this behind a flag is acceptable for now. I believe Android can support the same process of registering and receiving background notifications, even if the user denies notification permissions. However, it might require some investigation and adjustments to make it work properly, as the current initialization process seems to return early if permissions are denied. Eventually, we can look into expanding support for Android as well. Once both platforms support the same functionality, we can reassess whether the flag is still needed in a future major release. As for the flag’s description, how would the following update sound?
Additionally, I’m considering adding this statement at the end:
|
Sure, feel free to wordsmith that however you'd like |
Co-authored-by: エリス <[email protected]>
Description
ios.forceRegister
boolean
false
On iOS, notification permissions only control user-facing notifications. Silent/invisible notifications can be received and handled in the background even when the user denies notification permissions.
When forceRegister is true, registerForRemoteNotifications will be called on init even if requestAuthorizationWithOptions comes back with granted=FALSE.
Related Issue
#335
Motivation and Context
How Has This Been Tested?
In my app, I observe that without
forceRegister
, if the user denies notification permissions prior toPushNotification.init()
, neitherpush.on('registration', ...)
norpush.on('error', ...)
are invoked.When
forceRegister
= true, and the same scenario,push.on('registration', ...)
is called and an APNS token is established.When
forceRegister
= false or not defined, the behavior is the same as before.Screenshots (if appropriate):
Types of changes
Checklist:
I have added tests to cover my changes.All new and existing tests passed.