Push Notification permission prompt - unrecognized permission: (null)


#1

Hi

I was using v23 and the Push Notifications worked fine. The only problem was that if the user said no, then the app would freeze. After searching around, people suggested to upgrade the version, so I updated to the latest one, v27. However, I now get this error when it comes to opening the push notification alert:

[Unhandled promise rejection: Error: Unrecognized permission: (null)]
- node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:121:42 in createErrorFromErrorData
- node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:78:57 in <unknown>

The code I’m using is the same as the template on the Expo site, which was working before, but here it is:

registerForPushNotificationsAsync = async () => {
    console.log('start register for push notifications')
    // Android remote notification permissions are granted during the app
    // install, so this will only ask on iOS


    let { status } = await Permissions.askAsync(Permissions.REMOTE_NOTIFICATIONS)

    console.log('status: '+status)

    // Stop here if the user did not grant permissions
    if (status !== 'granted') {
      console.log('clicked no')
      this.props.navigation.navigate('CreateAccount')
      return
    }

I’ve already tried deleting my npm_modules and re-installing, but it didn’t work. Can’t find anything online, so thought I would ask here.

Thanks


#2

The problem is REMOTE_NOTIFICATIONS. There was a change in SDK 26, so now you should ask for NOTIFICATIONS instead.


#3

Thanks very much, that was it! I’ll remember to check the docs thoroughly next time after updating the version.


closed #4

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.