Leanplum / Leanplum-Android-SDK

Leanplum's integrated solution delivers meaningful engagement across messaging and the in-app experience.
https://www.leanplum.com
Apache License 2.0
46 stars 40 forks source link

Android 12 trampoline restrictions #470

Closed hborisoff closed 3 years ago

hborisoff commented 3 years ago
What Where/Who
JIRA Issue SDK-491
People Involved @hborisoff

Background

This change makes the SDK compliant with Android 12 trampoline restrictions.

Until now a click on notification is handled in LeanplumPushReceiver which decides what to do next and what activity should be started. With version 12 notifications must start activity directly. This results in a change in the LeanplumPushService.handleNotification to assign the correct activity to the notification intent and bypass the LeanplumPushReceiver.

If we bypass the receiver we can't make the correct tracking of the Push Opened and Open events and also we can't run the Open Action of the message. To solve it the message is attached as an extra in the notification intent and it is processed in the ActivityLifecycleCallbacks object.

Important to note is that if Open Action of the push notification is Open URL which opens another app this will result in not tracking the Push Opened and Open events because we can't get feedback when the user clicks the notification.

Another important note is that when main activity is set as singleTop the client must call setIntent(intent) inside Activity.onNewIntent method to allow the lifecycle callback to work properly.

Check the docs for further details about the implementation.