Saturday, 21 January 2023

ReactNative and PermissionsAndroid 0.71 vs 0.70: POST_NOTIFICATION vs POST_NOTIFICATIONS and IllegalArgumentException

On https://reactnative.dev/docs/0.70/permissionsandroid it shows that this permission is available for verion 0.70:

POST_NOTIFICATION: 'android.permission.POST_NOTIFICATION'

On https://reactnative.dev/docs/permissionsandroid (version 0.71) it shows that the same persmission is then with an "S" at the end:

POST_NOTIFICATIONS: 'android.permission.POST_NOTIFICATIONS'

Is this a typo?

In either case, if I use any of the above, the app crashes with

IllegalArgumentException: permission is null at android.app.ContextImpl.checkSelfPermission(ContextImpl.java:2222) at android.content.ContextWrapper.checkSelfPermission(ContextWrapper.java:931) at com.facebook.react.modules.permissions.PermissionsModule.requestPermission(PermissionsModule.java:105) at java.lang.reflect.Method.invoke(Method.java)

when doing this:

async requestPermission() {
    try {
      const granted = await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.POST_NOTIFICATION, // or POST_NOTIFICATIONS
        {
          'title': 'TEST',
          'message': I18n.t('permissions.locationPermissionMessage')
        }
      )
      if (granted === PermissionsAndroid.RESULTS.GRANTED) {
        
      } else {
      }
    } catch (err) {
     
    }
  }

The permission is in the AndroidManifest file, confirmed.



from ReactNative and PermissionsAndroid 0.71 vs 0.70: POST_NOTIFICATION vs POST_NOTIFICATIONS and IllegalArgumentException

No comments:

Post a Comment