Skip to content

Commit 11f05d6

Browse files
committed
Wrap recovering in try-catch
1 parent c7d0e40 commit 11f05d6

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

com.unity.mobile.notifications/Runtime/Android/Plugins/com/unity/androidnotifications/UnityNotificationUtilities.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,17 @@ protected static Class<?> getOpenAppActivity(Context context, boolean fallbackTo
524524
}
525525

526526
protected static Notification.Builder recoverBuilder(Context context, Notification notification) {
527-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
528-
Notification.Builder builder = Notification.Builder.recoverBuilder(context, notification);
529-
// extras not recovered, transfer manually
530-
builder.setExtras(notification.extras);
531-
return builder;
527+
try {
528+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
529+
Notification.Builder builder = Notification.Builder.recoverBuilder(context, notification);
530+
// extras not recovered, transfer manually
531+
builder.setExtras(notification.extras);
532+
return builder;
533+
}
534+
} catch (Exception e) {
535+
Log.e(TAG_UNITY, "Failed to recover builder for notification!", e);
536+
} catch (OutOfMemoryError e) {
537+
Log.e(TAG_UNITY, "Failed to recover builder for notification!", e);
532538
}
533539

534540
return recoverBuilderCustom(context, notification);

0 commit comments

Comments
 (0)