(ios) Fix foreground notifications not being displayed after calling grantPermission when permissions haven't been previously granted #800
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.
PR Type
What kind of change does this PR introduce?
PR Checklist
Please check your PR fulfills the following requirements:
Bugfixes:
What is the purpose of this PR?
Currently, calling
grantPermission
on ios while permissions have not been granted will cause received foreground notifications (notifications with"notification_foreground": "true"
) to not be displayed until app is restarted. This seems to happen because thegrantPermission
function changes the notification center delegate if called and permissions have not been already granted:cordova-plugin-firebasex/src/ios/FirebasePlugin.m
Lines 303 to 310 in ab66059
Meanwhile the completionHandler for the permission request never sets this back to the original value
cordova-plugin-firebasex/src/ios/FirebasePlugin.m
Lines 321 to 331 in ab66059
The notification center delegate is first set here during app startup:
cordova-plugin-firebasex/src/ios/AppDelegate+FirebasePlugin.m
Line 80 in ab66059
The fix included in this PR simply sets the notification center delegate back to the AppDelegate if permissions were granted successfully.
Does this PR introduce a breaking change?
What testing has been done on the changes in the PR?
This change has been tested in a production app
What testing has been done on existing functionality?
Other information