fix(android): prevent permission dialog appearing when already denied #325
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Prevent second permission dialog from appearing on second launch if user already selected "Don't allow".
Description
If the user selects "Don't allow" for the push notification permission, it is expected that the notification dialog will not reappear on subsequent launches asking the same question.
It is assumed that the user's decision reflects their intent.
If they made a mistake, they can go to the app settings to manually enable the permission.
Additionally, the unusual behavior of the permission dialog reappearing occurs only on the second launch; on the third or later launches, the dialog does not appear.
The changes in this PR ensure that the decision made by the app user is acknowledged and the permission will not be requested again.
This behavior was achieved by adding a call to
shouldShowRequestPermissionRationale
before invoking therequestPermissions
method, which aligns with the guidance provided in the Android documentation.Reference: Android Documentation - requestPermissions
Related Issue
n/a
How Has This Been Tested?
Additional Test:
Screenshots (if appropriate):
Types of changes
Checklist: