Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push permission on Android 13 devices not requested until after sending first push to the user #490

Open
alex-a-pereira opened this issue Jan 25, 2023 · 1 comment

Comments

@alex-a-pereira
Copy link

Description of problem

Android devices running Android 13 (API level 33) require that the user opts-in to receiving push notifications.

For apps targeting API level 33, there are sdk methods exposed to trigger the prompt. I'm not sure if these methods are handled by iterable-

However, for apps targeting API level 32 (Android 12) and below, the prompt is triggered only after the first time a NotificationChannel is created see details here. It looks like in the iterable-android-sdk, a NotificationChannel is only constructed after iterable sends a push notification to the device.

Example: after sending a push notification to the device, these logs appeared. A push notification was not displayed on the device of course.

  💚 Message data payload: {body=<OMMITED> itbl={"defaultAction":{"type":"mightierparentapp:\/\/settings"},"isGhostPush":false,"messageId":"4b75cb45e4024b368fa1e2ad6db59b02","actionButtons":[],"templateId":5612737}, title=<OMMITED>}
  💚 Iterable push received {body=<OMMITED>, itbl={"defaultAction":{"type":"mightierparentapp:\/\/settings"},"isGhostPush":false,"messageId":"4b75cb45e4024b368fa1e2ad6db59b02","actionButtons":[],"templateId":5612737}, title=<OMMITED>}
  💚 channel name: null
   !!!! LOOK HERE !!!!!
  💚 Creating notification: channelId = com.neuromotion.mightierparentapp channelName = iterable channel channelDescription = 
  💚 iconID: 2131492867
  💚 Request code = 381045786
  💚 Request code = 2019305240

When I opened the app after these logs, I saw the android prompt in the screenshot below (note: I'm using an emulator here but physical devices running Android 13 show the same behavior)

image

Questions

Is there any way to force the NotificationChannel to be constructed earlier, possibly at app launch?

The android docs for NotificationChannel specify that it's safe to create a notification at app startup:

Creating an existing notification channel with its original values performs no operation, so it's safe to call this code when starting an app.

Version Info

My app was built with react-native, but this appears to be an issue more relevant to the android-sdk.
Relevent version info:

"@iterable/react-native-sdk": "1.3.1",
  -> android sdk 3.4.5
@Ayyanchira
Copy link
Member

Thanks for writing in and for your suggestion @alex-a-pereira.
At present, unfortunately, we don't create channels right on the initialization and rather wait for the first notification for channel creation.
Will definitely have this put up in our future feature set for discussion and prioritization.

Until then, a workaround would be to have a custom firebase class implementation as mentioned in support docs and have channel created on the app start to trigger the OS permission. Again for react native, it will have to be written in the android native part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants