question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Checking Notification Permissions Android not working

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
Dallas62commented, Aug 17, 2020

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); });
1reaction
TommyLeongcommented, Aug 17, 2020

Thanks @Dallas62, finally I get you now. 🙏🏻

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - How to check if my app is allowed to show notification
I tested this by manually changing the notifications permissions in settings and it worked fine, boolean was returned correctly in both cases.
Read more >
Notification runtime permission - Android Developers
Best practices · Update your app's target SDK version · Wait to show notification permission prompt · Request the permission in context ·...
Read more >
Change app permissions on your Android phone - Google Help
An app will send a notification to ask for permission to use features on your phone, which you can ... Some of these...
Read more >
Top Tips for Adopting Android's Notification Permission
You can check by first calling the NotificationManager#areNotificationsEnabled() API. After the user upgrades their device to Android 13, the API reflects the ...
Read more >
Android is finally gonna ask you about notifs before bugging ...
Android 13 is bringing a new run time notification permission. ... but essential component of how notifications work — and I hope I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found