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.

PushNotification.requestPermissions needs documentation

See original GitHub issue

PushNotification.requestPermissions is missing documentation. Investigating the code suggests that this method returns a promise but the promise never seems to resolve or reject. Would someone with knowledge around this be willing to add documentation for this?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:20
  • Comments:19

github_iconTop GitHub Comments

10reactions
anshuul-kaicommented, Apr 6, 2018

Sure, I’m more than happy to share my implementation below @philwilks . Notice how Android doesn’t require you to request permissions.

      new Promise(resolve => {
        if (Platform.OS === 'ios') {
          PushNotification.checkPermissions(({ alert, badge, sound }) => {
            if (!alert || !badge || !sound) {
              PushNotification.requestPermissions();
            }
            resolve();
          });
        } else {
          resolve();
        }
      }).then(() => {
        PushNotification.cancelAllLocalNotifications();
        PushNotification.localNotificationSchedule(yourNotificationObject);
      });
9reactions
remigallegocommented, Jun 14, 2018

@a-koka This sadly does not work. the Promise does not wait for requestPermissions(), which itself is a buggy Promise that needs fixing from the react-native core.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the react-native-push-notification ... - Snyk
To help you get started, we've selected a few react-native-push-notification.requestPermissions examples, based on popular ways it is used in public ...
Read more >
Notification.requestPermission() - Web APIs - MDN Web Docs
The requestPermission() method of the Notification interface requests permission from the user for the current origin to display notifications.
Read more >
Asking Permission to Use Notifications - Apple Developer
Request permission to display alerts, play sounds, or badge the app's icon in response to a notification.
Read more >
How to Prompt for Push Permissions with an In-App Message
requestPermissions with android.permission. ... Follow the Android 13 Push Notification Developer Update Guide. See the IAM Click Actions guide for more ...
Read more >
Notification runtime permission - Android Developers
Note: Apps don't need to request the POST_NOTIFICATIONS permission in order to launch a foreground service. However, apps must include a notification when ......
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