Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRASH - When the launch url is invalide #1954

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import android.app.AlertDialog;
import android.app.Application;
import android.app.NotificationManager;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
Expand Down Expand Up @@ -183,6 +184,13 @@ public interface OSNotificationOpenedHandler {
void notificationOpened(OSNotificationOpenedResult result);
}

/**
* Fires delegate when starting destination Activity fail.
*/
public interface OSNotificationOpenedError {
void onOpenDestinationActivityNotFoundError(ActivityNotFoundException exception);
}

/**
* An interface used to process a OneSignal In-App Message the user just tapped on.
* <br/>
Expand Down Expand Up @@ -404,6 +412,7 @@ static Activity getCurrentActivity() {
static OSRemoteNotificationReceivedHandler remoteNotificationReceivedHandler;
static OSNotificationWillShowInForegroundHandler notificationWillShowInForegroundHandler;
static OSNotificationOpenedHandler notificationOpenedHandler;
static OSNotificationOpenedError notificationOpenedError;
static OSInAppMessageClickHandler inAppMessageClickHandler;

// Is the init() of OneSignal SDK finished yet
Expand Down Expand Up @@ -807,6 +816,10 @@ public static void setNotificationOpenedHandler(@Nullable OSNotificationOpenedHa
fireCallbackForOpenedNotifications();
}

public static void setNotificationOpenedError(@Nullable OSNotificationOpenedError callback) {
notificationOpenedError = callback;
}

public static void setInAppMessageClickHandler(@Nullable OSInAppMessageClickHandler callback) {
inAppMessageClickHandler = callback;
}
Expand Down Expand Up @@ -2459,8 +2472,14 @@ static void openDestinationActivity(
}
} catch (JSONException e) {
e.printStackTrace();
} catch (ActivityNotFoundException e) {
if (notificationOpenedError != null) {
notificationOpenedError.onOpenDestinationActivityNotFoundError(e);
} else {
e.printStackTrace();
}
}
}
}

private static boolean shouldInitDirectSessionFromNotificationOpen(Activity context, final JSONArray data) {
if (inForeground) {
Expand Down