I want to check push notification permission for both ios and android. I want to see if user has switched off the push notification permission from his device settings. Is there any plugin or any code i can take reference from if needed to be coded in native.
Asked
Active
Viewed 1.6k times
3 Answers
5
You can check react-native-permissions npm. After integrating you can use it like:
componentDidMount() {
Permissions.check('notification').then(response => {
// Response is one of: 'authorized', 'denied', 'restricted', or 'undetermined'
this.setState({ photoPermission: response })
})
}
There is another library that can help (I have not used it).
There is also native implementation for as suggested here.
rptwsthi
- 9,983
- 10
- 68
- 107
-
1but 'notification' permission using react-native-permission only works with ios and not with android. – mayank goyal Nov 19 '18 at 09:49
-
That is why added "another library". – rptwsthi Nov 19 '18 at 09:50
4
Official way https://github.com/react-native-community/react-native-permissions#checknotifications
import {requestNotifications} from 'react-native-permissions';
requestNotifications(['alert', 'sound']).then(({status, settings}) => {
// …
});
FDisk
- 7,389
- 2
- 43
- 50
0
Android:
Actually the Push Notification permission lie in Normal Category Permission like INTERNET permission not in Dangerous Category Permission.
You don't have to ask for Push Notification permissions.
More details is here, https://stackoverflow.com/a/37294287/7188778
Andrii Sikora
- 31
- 1
- 4