Skip to content

Commit 9b7850a

Browse files
Added the metadata check, I think this will overlap with the current check, and should be done after, at other point of the app open process.
1 parent 978380a commit 9b7850a

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

Examples/OneSignalDemo/local.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
# Location of the SDK. This is only used by Gradle.
55
# For customization when using a Version Control System, please read the
66
# header note.
7-
#Tue Jul 23 19:22:28 PDT 2019
7+
#Wed Jan 27 19:24:35 ART 2021
88
ndk.dir=/Users/mikechoch/Library/Android/sdk/ndk-bundle
9-
sdk.dir=/Users/mikechoch/Library/Android/sdk
9+
sdk.dir=/Users/gonzalonarbaiz/Library/Android/sdk

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSNotificationOpenedResult.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public OSNotificationOpenedResult(OSNotification notification, OSNotificationAct
5858
// Configure 5 second timeout - max time we expect the application to call onResume
5959
// User can disable OneSignal application open by setting on the manifest:
6060
// <meta-data android:name="com.onesignal.NotificationOpened.DEFAULT" android:value="DISABLE" />
61+
// User can also disable OneSignal from opening the url on default webview setting on the manifest:
62+
// <meta-data android:name="com.onesignal.suppressLaunchURLs" android:value="true" />
6163
// If the user does this, we need to identify if the notification click was the way the user come back to the application (Session tracking)
6264
timeoutHandler = OSTimeoutHandler.getTimeoutHandler();
6365
timeoutRunnable = new Runnable() {

OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignal.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,13 +2149,15 @@ public void run() {
21492149

21502150
boolean urlOpened = false;
21512151
boolean defaultOpenActionDisabled = "DISABLE".equals(OSUtils.getManifestMeta(context, "com.onesignal.NotificationOpened.DEFAULT"));
2152+
boolean launchUrlSuppress = "true".equals(OSUtils.getManifestMeta(context, "com.onesignal.suppressLaunchURLs"));
21522153

2153-
if (!defaultOpenActionDisabled)
2154+
if (!defaultOpenActionDisabled && !launchUrlSuppress)
21542155
urlOpened = openURLFromNotification(context, data);
21552156

2156-
logger.debug("handleNotificationOpen from context: " + context + " with fromAlert: " + fromAlert + " urlOpened: " + urlOpened + " and defaultOpenActionDisabled: " + defaultOpenActionDisabled);
2157+
logger.debug("handleNotificationOpen from context: " + context + " with fromAlert: " + fromAlert + " urlOpened: " + urlOpened + " defaultOpenActionDisabled: " + defaultOpenActionDisabled
2158+
+ " launchUrlSuppress: " + defaultOpenActionDisabled );
21572159
// Check if the notification click should lead to a DIRECT session
2158-
if (shouldInitDirectSessionFromNotificationOpen(context, fromAlert, urlOpened, defaultOpenActionDisabled)) {
2160+
if (shouldInitDirectSessionFromNotificationOpen(context, fromAlert, urlOpened, defaultOpenActionDisabled, launchUrlSuppress)) {
21592161
applicationOpenedByNotification(notificationId);
21602162
}
21612163

@@ -2188,13 +2190,15 @@ static boolean startOrResumeApp(Activity inContext) {
21882190
* 1. App is not an alert
21892191
* 2. Not a URL open
21902192
* 3. Manifest setting for com.onesignal.NotificationOpened.DEFAULT is not disabled
2191-
* 4. App is coming from the background
2192-
* 5. App open/resume intent exists
2193+
* 4. Manifest setting for com.onesignal.suppressLaunchURLs is not true
2194+
* 5. App is coming from the background
2195+
* 6. App open/resume intent exists
21932196
*/
2194-
private static boolean shouldInitDirectSessionFromNotificationOpen(Activity context, boolean fromAlert, boolean urlOpened, boolean defaultOpenActionDisabled) {
2197+
private static boolean shouldInitDirectSessionFromNotificationOpen(Activity context, boolean fromAlert, boolean urlOpened, boolean defaultOpenActionDisabled, boolean launchUrlSuppress) {
21952198
return !fromAlert
21962199
&& !urlOpened
21972200
&& !defaultOpenActionDisabled
2201+
&& !launchUrlSuppress
21982202
&& !inForeground
21992203
&& startOrResumeApp(context);
22002204
}

0 commit comments

Comments
 (0)