Skip to content

Commit 1ccbce9

Browse files
committed
Added logic to create propper intent based on URL type
1 parent 064f312 commit 1ccbce9

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,7 @@ private static boolean openURLFromNotification(Context context, JSONArray dataAr
14001400
int jsonArraySize = dataArray.length();
14011401

14021402
boolean urlOpened = false;
1403+
Intent intent = null;
14031404

14041405
for (int i = 0; i < jsonArraySize; i++) {
14051406
try {
@@ -1411,13 +1412,16 @@ private static boolean openURLFromNotification(Context context, JSONArray dataAr
14111412

14121413
if (customJSON.has("u")) {
14131414
String url = customJSON.optString("u", null);
1414-
if (!url.contains("://"))
1415-
url = "http://" + url;
14161415

1417-
Intent intent = new Intent(Intent.ACTION_MAIN, Uri.parse(url.trim()));
1418-
intent.addCategory(Intent.CATEGORY_LAUNCHER);
1416+
if (!url.contains("http")) {
1417+
intent = new Intent(Intent.ACTION_MAIN, Uri.parse(url.trim()));
1418+
intent.addCategory(Intent.CATEGORY_LAUNCHER);
1419+
}
1420+
else
1421+
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url.trim()));
14191422

14201423
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET |Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
1424+
14211425
context.startActivity(intent);
14221426
urlOpened = true;
14231427
}

0 commit comments

Comments
 (0)