Skip to content

Commit 7f76298

Browse files
committed
rm all the reverse bits from Activity Trampolining
This commit focuses on removing all logic that setups up multiple Activities and flags to build a "Reverse Activity Trampoline". This is Part 1 of required changes, this commit results in the app not opening, resuming, or opening launch URLs, the behavior of the click being tracked is still working via the invisible NotificationOpenedReceiver Activity. This gives us a clean starting state for the next commit where we we will add logic to the notification open event to Activity Trampoline forward to the intended Activity.
1 parent 0443c85 commit 7f76298

File tree

1 file changed

+7
-34
lines changed

1 file changed

+7
-34
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/GenerateNotificationOpenIntent.kt

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,11 @@ class GenerateNotificationOpenIntent(
5151
context,
5252
notificationOpenedClassAndroid22AndOlder
5353
)
54-
55-
if (getIntentVisible() == null) {
56-
// If we don't show a visible Activity put OneSignal's invisible click tracking
57-
// Activity on it's own task so it doesn't resume an existing one once it closes.
58-
intent.addFlags(
59-
Intent.FLAG_ACTIVITY_NEW_TASK or
60-
Intent.FLAG_ACTIVITY_MULTIPLE_TASK or
61-
Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
62-
)
63-
}
64-
54+
intent.addFlags(
55+
Intent.FLAG_ACTIVITY_NEW_TASK or
56+
Intent.FLAG_ACTIVITY_MULTIPLE_TASK or
57+
Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
58+
)
6559
return intent
6660
}
6761

@@ -83,31 +77,10 @@ class GenerateNotificationOpenIntent(
8377
oneSignalIntent: Intent,
8478
): PendingIntent? {
8579
val flags = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
86-
val launchIntent = getIntentVisible()
87-
?:
88-
// Even though the default app open action is disabled we still need to attach OneSignal's
89-
// invisible Activity to capture click event to report click counts and etc.
90-
// You may be thinking why not use a BroadcastReceiver instead of an invisible
91-
// Activity? This could be done in a 5.0.0 release but can't be changed now as it is
92-
// unknown if the app developer will be starting there own Activity from their
93-
// OSNotificationOpenedHandler and that would have side-effects.
94-
return PendingIntent.getActivity(
95-
context,
96-
requestCode,
97-
oneSignalIntent,
98-
flags
99-
)
100-
101-
102-
// This setups up a "Reverse Activity Trampoline"
103-
// The first Activity to launch will be oneSignalIntent, which is an invisible
104-
// Activity to track the click, fire OSNotificationOpenedHandler, etc. This Activity
105-
// will finish quickly and the destination Activity, launchIntent, will be shown to the user
106-
// since it is the next in the back stack.
107-
return PendingIntent.getActivities(
80+
return PendingIntent.getActivity(
10881
context,
10982
requestCode,
110-
arrayOf(launchIntent, oneSignalIntent),
83+
oneSignalIntent,
11184
flags
11285
)
11386
}

0 commit comments

Comments
 (0)