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

Fix: API 30+ fix for opening Pinpoint push notification links #2924

Merged
merged 4 commits into from
Jun 8, 2022
Merged
Changes from 2 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 @@ -18,6 +18,7 @@
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
Expand Down Expand Up @@ -812,8 +813,12 @@ private void openURL(final String url, final boolean noSchemeValidation) {
final Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(validatedUrl));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (intent.resolveActivity(pinpointContext.getApplicationContext().getPackageManager()) != null) {

// Querying packages now requires query manifest flag, so we instead try/catch the attempt
try {
pinpointContext.getApplicationContext().startActivity(intent);
} catch (ActivityNotFoundException e) {
log.error("Couldn't find an app to open ACTION_VIEW Intent.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include e or e.getMessage for additional context on error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, but it won't really provide any additional context. In this instance the only scenario here is that the user does not have a browser app installed.

}
}

Expand Down