Reputation: 49
react-native firebase request permissions always result in an exception.
I am trying to give the user the option to allow notifications in my react-native app. So, when the user install my react-native app an alert will be shown and he can choose whether to allow notifications on the app or not. I am using react-native-firebase to handle this. however, the firebase "requestPermission" function always fails whatever I click "allow" or "Not Allow".
firebase.messaging().requestPermission()
.then(() => {
console.log('User Now Has Permission')
})
.catch((error) => {
console.log('Error', error)
})
Upvotes: 4
Views: 13937
Reputation: 49
thank you all, I resolved it via setting requestPermissions: false, in
configurePushNotification = (callBack) => {
PushNotification.configure({
// (required) Called when a remote or local notification is opened or received
onNotification: callBack,
// IOS ONLY (optional): default: all - Permissions to register.
permissions: {
alert: true,
badge: true,
sound: true,
},
// Should the initial notification be popped automatically
// default: true
popInitialNotification: true,
/**
* (optional) default: true
* - Specified if permissions (ios) and token (android and ios) will requested or not,
* - if not, you must call PushNotificationsHandler.requestPermissions() later
*/
requestPermissions: false,
})
}
Upvotes: 0