React-native-push-notification: Checking Notification Permissions Android not working

Created on 17 Aug 2020  路  6Comments  路  Source: zo0r/react-native-push-notification

Checking Notification Permissions Android not working

I'm trying to get the Android App Notification status with the check permission method here. Here's the code to check permission in Android

According the readme file, I did the following..

  1. yarn add react-native-push-notification
  2. I have not performed any manual installation as stated here
  3. I write my code as below
  4. Android has no respond, but iOS did come back with expected respond.
import PushNotification from 'react-native-push-notification';
async componentDidMount(){
PushNotification.checkPermission().then((response) => {
      if (response && response.alert !== 0) {
        console.log('hi4')
        console.log(response)
        return; 
      }
      console.log('hi5')
        console.log(response)
    });
}

Am I doing anything wrong here to check the App Notification status in Android?

For iOS, I have this install.
yarn add @react-native-community/push-notification-ios

Most helpful comment

https://github.com/zo0r/react-native-push-notification#checking-notification-permissions

PushNotification.checkPermissions(callback: Function) Check permissions

callback will be invoked with a permissions object:

alert: boolean
badge: boolean
sound: boolean

PushNotification.checkPermissions(function(permissions) {  console.log(permissions); });

All 6 comments

Hi @TommyLeong
As the Readme define that method, this is not supposed to be a promise. Actually only the iOS library allow this.
Regards

Hi @TommyLeong
As the Readme define that method, this is not supposed to be a promise. Actually only the iOS library allow this.
Regards

What does that suppose to mean? Is that a known bug for this lib?

This is not a "bug", this library use callbacks, not promises.

This is not a "bug", this library use callbacks, not promises.

Possible to provide sample code?

https://github.com/zo0r/react-native-push-notification#checking-notification-permissions

PushNotification.checkPermissions(callback: Function) Check permissions

callback will be invoked with a permissions object:

alert: boolean
badge: boolean
sound: boolean

PushNotification.checkPermissions(function(permissions) {  console.log(permissions); });

Thanks @Dallas62, finally I get you now. 馃檹馃徎

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanDance picture DanDance  路  3Comments

sungjinoh picture sungjinoh  路  3Comments

NiuQiaoling picture NiuQiaoling  路  3Comments

cookienawer picture cookienawer  路  3Comments

Kiran0791 picture Kiran0791  路  3Comments