I have found that on iOS firebase.messaging().hasPermission() will only return true if the user has allowed notifications AND if the banner alert style is also selected. In practice a notification will still be received if the banner style is disabled (as expected) even though the hasPermission returns false.
See attached image to show the iOS Notification settings.
import firebase from 'react-native-firebase';
checkFirebasePermissions = () => {
firebase.messaging().hasPermission()
.then((enabled) => {
if (enabled) {
// NOTIFICATIONS ENABLED
} else {
// NOTIFICATIONS DISABLED
}
})
}

this still happens on latest 6.0.1 . any updates ?
6.0.3 here as well
Please forgive that this is a bit of deflection, but I highly recommend using the react-native-permissions module for permissions management that isn't vital to the react-native-firebase API usage. What I mean specifically is that I believe you have to call requestPermission() from react-native-firebase for the proper connection / listening to happen on messaging, but prior to calling that I would use react-native-permissions to actually manage the permissions to my liking and call requestPermission if it made sense.
Permissions handling on iOS has gotten pretty intricate on iOS13 and as far as I know react-native-permissions is the most up to date module for handling it
@mikehardy is react-native-permissions the suggested and replaced approach?
shall I start using it ? thanks
All I can say it is what I use, and I know it as a well maintained very up to date, focused permissions solution. So, strong personal recommendation at least
thanks,
and another questions any plan to write hasPermission based on react-native-permissions?
If I had a vote, I'd go the opposite way and delete everything permission-related from react-native-firebase, deferring 100% to react-native-permissions. Permissions is non-core to a firebase library, no reason for it to be here with other options available, especially when they are high quality like react-native-permissions
I'm agree, with a link to react-native-permissions in docs it can be done
thanks 馃挴
Hi,
I took a look at the issue and I've verified that the issue is related to the iOS native implementation of hasPermission. It should be be checking authorizationStatus instead of alertSetting
When I replaced it with the following code it worked perfectly.
BOOL hasPermission = [RCTConvert BOOL:@(settings.authorizationStatus == UNNotificationSettingEnabled)];
Unfortunately I'm not running the latest version of RN-Firebase so I have not created a pull request. But I hope this helps someone.
@jsiServiceNSW would still be great to create a pull request if you can, either way if you aren't using https://github.com/ds300/patch-package for things like this you might give it a look, this is the perfect use case when you have to maintain a little change like that
We've updated & improved the permissions API in #3339 so I'm going to go ahead and close this as this should no longer be an issue. Thanks for the report.
Most helpful comment
If I had a vote, I'd go the opposite way and delete everything permission-related from react-native-firebase, deferring 100% to react-native-permissions. Permissions is non-core to a firebase library, no reason for it to be here with other options available, especially when they are high quality like react-native-permissions