iterable-android-sdk icon indicating copy to clipboard operation
iterable-android-sdk copied to clipboard

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

Open alex-a-pereira opened this issue 2 years ago • 1 comments

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

alex-a-pereira avatar Jan 25 '23 14:01 alex-a-pereira

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.

Ayyanchira avatar Feb 26 '23 17:02 Ayyanchira