Search code examples
iosreact-nativepush-notificationapple-push-notificationsreact-native-push-notification

How to detect if an alert was shown in react native?


I am using react-native-push-notification and I need to change screens only after a user has made a decision whether or not they want push notifications from my app. But once onRegister: function(token) is encountered, a system alert is automatically shown by iOS. How do I listen to the user making a selection on this system alert box?


Solution

  • To listen to the user's decision.

    PushNotification.requestPermissions().then((response: any) => {
      if (response && response.alert !== 0) {
        // Allow
        return; 
      }
      // Decline
    });