I’m using react-native-permissions library to request permissions in our react-native app.
Currently I’m implementing push notification. For Android I can request Push Notification Permission with native modal using request(PERMISSIONS.ANDROID.POST_NOTIFICATIONS)
. But for iOS I don’t see a way to request push permission.
But
await checkNotifications()
.then(({ status, settings }) => {
console.log('CHECK STATUS: ', status);
console.log('CHECK SETTINGS: ', settings);
})
.catch((err) => console.log('CHECK ERROR: ', err));
works though it doesn’t open the modal.
How can I request the push permission in iOS ?
2
Answers
Found it. It can be done with
RNPermissions.requestNotifications
methodFor iOS I use requestNotifications from react-native-permissions as follow:
And call it on useEffect as follow:
IMPORTANT NOTE: Don’t forget to set NSUserNotificationsUsageDescription in ios/app_name/Info.plist:
And add this to ios/app_name/PodFile
For Android it easy just use:
And add this in AndroidManifest.xml: