braze-inc / braze-android-sdk

https://www.braze.com
Other
19 stars 7 forks source link

[Bug]: Notification runtime permission, POST_NOTIFICATIONS #9

Closed MrJero closed 1 year ago

MrJero commented 1 year ago

Braze Android SDK Version

26.0.0

Steps To Reproduce

targetSdkVersion: 33 implementation "com.braze:android-sdk-ui:26.0.0"

Expected Behavior

We should show the notification permission flow.

Actual Incorrect Behavior

The notification permission flow is not working on Android 13.

Verbose Logs

No response

Additional Information

Hi there,

Updating the targetSdkVersion to 33 we’re experimenting with some issues with the Notification Permission.

In our project we're using:

targetSdkVersion: 33 implementation "com.braze:android-sdk-ui:26.0.0"

We realized in devices with Android 13 the Push notification permission is not shown. So, since from API 33 and above in Android we need to ask for that permission in a different way, it's called POST_NOTIFICATIONS. https://developer.android.com/develop/ui/views/notifications/notification-permission

just wondering if this is something that you will address and give us support for that, or is something that we should handle on our side?

Thanks in advance Jero

radixdev commented 1 year ago

Hi @MrJero ,

We would need a few things to proceed with an investigation here:

  1. Detailed reproduction steps.
  2. Verbose logs of the issue occurring.
  3. The device model and API version of the device used for the test.

Additionally, our SDK already asks for that permission in https://github.com/braze-inc/braze-android-sdk/blob/4b7004ea60822fa4ff058a503969078923c70c19/android-sdk-ui/src/main/AndroidManifest.xml#L4.

MrJero commented 1 year ago

Hi @radixdev Basically before updating the targetSdkVersion to 33, as soon as we called the init function the notification permission flow was shown.

private fun initBraze() {
   BrazeLogger.logLevel = if (BuildConfig.DEBUG) Log.WARN else BrazeLogger.SUPPRESS
   val sessionHandlingEnabled = true
   val registerInAppMessageManager = true
   val listener = BrazeActivityLifecycleCallbackListener(
       sessionHandlingEnabled,
       registerInAppMessageManager
   )
   (context as Application).registerActivityLifecycleCallbacks(listener)
}

I got it, but it seems like declaring in the manifest this permission is not enough.

Since API 33 and following we should request that permission in runtime, as Google says in this doc https://developer.android.com/develop/ui/views/notifications/notification-permission

Device: Samsung SM-G990E API 33 OS: Android 13

targetSdkVersion: 33 implementation "com.braze:android-sdk-ui:26.0.0"

sorry I can't send you the logs.

Thanks!

MrJero commented 1 year ago

more information:

MrJero commented 1 year ago

I solved it on our side, thanks!