简体   繁体   中英

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

根据官方的react-native-firebase 文档,您可以使用ios方法requestPermissions()来提示用户接受通知,但是由于该方法返回void,我如何检查用户是否拒绝通知?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM