0

According to the official react-native-firebase docs you can use the method requestPermissions() for ios to prompt the user about accepting notifications, but how can I check if the user declined it or not since said method returns void?

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
Gabriel Schneider
  • 605
  • 2
  • 6
  • 12

1 Answers1

1

Looks like the docs incorrectly state that it returns void, it actually returns a promise that resolves with an object - we'll get the docs updated.

On iOS 9 or below, there's no way to tell whether the user accepted or rejected the permissions popup - in this case the object will have a property called status with a value of "unknown"

In all other cases the object will have a granted property which is a boolean value of true/false.

iOS <= 9: https://github.com/invertase/react-native-firebase/blob/master/ios/RNFirebase/messaging/RNFirebaseMessaging.m#L291

iOS >= 10: https://github.com/invertase/react-native-firebase/blob/master/ios/RNFirebase/messaging/RNFirebaseMessaging.m#L302

EDIT: I've updated the docs to reflect the above.

Salakar
  • 6,016
  • 2
  • 18
  • 24