react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
741 stars 285 forks source link

Incorrect TS type for authorizationStatus in PushNotificationPermissions #196

Closed cmrigney closed 3 years ago

cmrigney commented 3 years ago

The type returned by PushNotificationIOS.requestPermissions(...) is PushNotificationPermissions which has a property authorizationStatus. The real type of the authorizationStatus property is a number but the TS type has it as an interface.

Currently, I have to do this to bypass the TypeScript error:

const permission = await PushNotificationIOS.requestPermissions(...)
const authorized = ((permission.authorizationStatus as any) as number) === PushNotificationIOS.AuthorizationStatus.UNAuthorizationStatusAuthorized
Naturalclar commented 3 years ago

@cmrigney thanks for raising the issue! The fix has been applied and published in v1.6.1 :tada:

cmrigney commented 3 years ago

@Naturalclar That was fast, thanks!