Closed upngo closed 1 year ago
Hey I was starting with this library and were stuck at exactly where my android phone never asked me for the Notification Permission.
VSCode automatically suggested me the PERMISSIONS after typing PermissionsAndroid. However nothing was suggested after PERMISSIONS as to the error "permission is null" made sense.
Could you think of a possibility why I'm getting the "permission is null" error? Would you mind to tell me your React-Native version. I'm using 0.67.4
right now
I'm using 0.71 which mentions POST_NOTIFICATIONS permission.
Looking at the 0.67 docs it doesn't. Probably because this was a permission that could be handled in your AndroidManifest.xml. Not sure why you're getting an error about permission being null though. Presumably you have a PermissionsAndroid
you could log.
Alternatively there are plugins to manage permissions you could try.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
The issue has been closed for inactivity.
This has cost us days of wasted debugging time. It's very unexpected that permissions are handled transparently on iOS but not on Android. Vote to re-open this issue.
The code snippet above works on recent versions of React Native, but older ones (e.g. 0.68) don't have that constant defined. In that case you can use the permission value directly like this:
PermissionsAndroid.request("android.permission.POST_NOTIFICATIONS" as any);
This remains an unresolved issue. Please re-open.
Thanks @tamlyn and @upngo for the solve!
For Android 33, permission must be asked for manually. Would be nice if this was mentioned in the docs.
A potential code sample could be
import { PermissionsAndroid } from 'react-native'; PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS);