5

I’ve built a React native Expo internal android application in the apk format. I’ve setup the app and firebase for push notification correctly.

But when I install the apk on an Android phone I always get status = denied when I call:

const { status } = await Notifications.requestPermissionsAsync(); 

It is like if the application has by default push notification declied. But then if I manually enable notification for my application in the android preferences, then all push notification is working well.

So I think my setup is correct but I don’t understand why I cannot ask to enable notification from my app with the Notifications.requestPermissionsAsync method. Is it a normal behaviour for apk?

Julien Bachmann
  • 753
  • 8
  • 18

1 Answers1

6

On Android 13 the prompt asking to grant the permission will not appear until at least one notification channel is created.

https://docs.expo.dev/versions/latest/sdk/notifications/#permissions

Freddy
  • 126
  • 2
  • Thanks a lot @Freddy, it is working well. Documentation was not up-to-date when I implemented it. But now it is OK and it works well. – Julien Bachmann Nov 09 '22 at 17:22
  • So in terms of the setup code https://docs.expo.dev/push-notifications/push-notifications-setup/ where do we call [setNotificationChannelAsync()](https://docs.expo.dev/versions/latest/sdk/notifications/#setnotificationchannelasyncidentifier-string-channel-notificationchannelinput-promisenotificationchannel--null) exactly? And I'm not sure what a "channel identifier" is as the first argument. – magician11 Nov 11 '22 at 08:44
  • 1
    ok the docs seem to have been updated with calling `Notifications.setNotificationChannelAsync`, but the prompt to allow notifications from Android doesn't come up. Doing a call to `Notifications.requestPermissionsAsync();` fails every time. With ``` Object { "android": Object { "importance": 0, "interruptionFilter": 1, }, "canAskAgain": false, "expires": "never", "granted": false, "status": "denied", } ``` I have to manually go into the permissions for the app to grant permissions for notifications to be able to get an expo token. What am I missing? – magician11 Dec 11 '22 at 22:46
  • @magician11 for me the prompt after registering channel shows but the token doesn't show up, also there isn't any error..., it's only on android 13... Did you ever resolve it? – Lucjan Grzesik Jan 20 '23 at 23:00
  • https://stackoverflow.com/a/76127440/4754175 this might help – Irfan Muhammad Apr 28 '23 at 08:02
  • i am also missing the system alert, no matter what i try. this somehow changes with an Expo SDK upgrade, because it wasn't a problem before. in addition, it is not related to Android 13 only, older versions behave the same. any ideas? the notification channel is awaited and created before any Notifications. access. – Donni May 12 '23 at 15:41