4

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.

mayank goyal
  • 43
  • 1
  • 1
  • 6

3 Answers3

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
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