Skip to content

Commit

Permalink
Merge pull request #706 from Iterable/MOB-7611
Browse files Browse the repository at this point in the history
Resolve error
  • Loading branch information
Ayyanchira authored Feb 28, 2024
2 parents e00f7ae + d23f0a0 commit 648a3d0
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ boolean executeAction(@NonNull Context context, @Nullable IterableAction action,
* `false` if the handler did not handle this URL and no activity was found to open it with
*/
private boolean openUri(@NonNull Context context, @NonNull Uri uri, @NonNull IterableActionContext actionContext) {
boolean uriHandled = false;
// Handle URL: check for deep links within the app
if (!IterableUtil.isUrlOpenAllowed(uri.toString())) {
return false;
Expand All @@ -73,6 +74,11 @@ private boolean openUri(@NonNull Context context, @NonNull Uri uri, @NonNull Ite
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(uri);

if (context.getPackageManager() == null) {
IterableLogger.e(TAG, "Could not find package manager to handle deep link:" + uri);
return false;
}

List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentActivities(intent, 0);
if (resolveInfos.size() > 1) {
for (ResolveInfo resolveInfo : resolveInfos) {
Expand All @@ -88,11 +94,11 @@ private boolean openUri(@NonNull Context context, @NonNull Uri uri, @NonNull Ite

if (intent.resolveActivity(context.getPackageManager()) != null) {
context.startActivity(intent);
return true;
uriHandled = true;
} else {
IterableLogger.e(TAG, "Could not find activities to handle deep link:" + uri);
return false;
}
return uriHandled;
}

/**
Expand Down

0 comments on commit 648a3d0

Please sign in to comment.