Gabriel Schneider
Gabriel Schneider

Reputation: 635

RN Firebase - How to check if the user accepted the permission for notifications on IOS

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?

Upvotes: 0

Views: 1012

Answers (1)

Salakar
Salakar

Reputation: 6304

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.

Upvotes: 1

Related Questions