Skip to content

Commit ffefed8

Browse files
committed
This exception no longer happens at this point
1 parent 68b4743 commit ffefed8

File tree

1 file changed

+34
-38
lines changed

1 file changed

+34
-38
lines changed

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

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -651,50 +651,46 @@ public void cancelAllNotifications() {
651651

652652
@Override
653653
public void onReceive(Context context, Intent intent) {
654-
try {
655-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
656-
if (KEY_NOTIFICATION_DISMISSED.equals(intent.getAction())) {
657-
int removedId = intent.getIntExtra(KEY_NOTIFICATION_DISMISSED, -1);
658-
if (removedId > 0) synchronized (UnityNotificationManager.class) {
659-
mVisibleNotifications.remove(removedId);
660-
}
661-
return;
654+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
655+
if (KEY_NOTIFICATION_DISMISSED.equals(intent.getAction())) {
656+
int removedId = intent.getIntExtra(KEY_NOTIFICATION_DISMISSED, -1);
657+
if (removedId > 0) synchronized (UnityNotificationManager.class) {
658+
mVisibleNotifications.remove(removedId);
662659
}
660+
return;
663661
}
664-
Object notification = getNotificationOrBuilderForIntent(context, intent);
665-
if (notification != null) {
666-
Notification notif = null;
667-
int id = -1;
668-
boolean sendable = notification instanceof Notification;
669-
if (sendable) {
670-
notif = (Notification) notification;
671-
id = notif.extras.getInt(KEY_ID, -1);
672-
} else {
673-
Notification.Builder builder = (Notification.Builder)notification;
674-
// this is different instance and does not have mOpenActivity
675-
if (builder == null) {
676-
Log.e(TAG_UNITY, "Failed to recover builder, can't send notification");
677-
return;
678-
}
679-
680-
Class openActivity;
681-
if (mUnityNotificationManager == null || mUnityNotificationManager.mOpenActivity == null) {
682-
openActivity = UnityNotificationUtilities.getOpenAppActivity(context, true);
683-
}
684-
else {
685-
openActivity = mUnityNotificationManager.mOpenActivity;
686-
}
687-
688-
id = builder.getExtras().getInt(KEY_ID, -1);
689-
notif = buildNotificationForSending(context, openActivity, builder);
662+
}
663+
Object notification = getNotificationOrBuilderForIntent(context, intent);
664+
if (notification != null) {
665+
Notification notif = null;
666+
int id = -1;
667+
boolean sendable = notification instanceof Notification;
668+
if (sendable) {
669+
notif = (Notification) notification;
670+
id = notif.extras.getInt(KEY_ID, -1);
671+
} else {
672+
Notification.Builder builder = (Notification.Builder)notification;
673+
// this is different instance and does not have mOpenActivity
674+
if (builder == null) {
675+
Log.e(TAG_UNITY, "Failed to recover builder, can't send notification");
676+
return;
690677
}
691678

692-
if (notif != null) {
693-
UnityNotificationManager.notify(context, id, notif);
679+
Class openActivity;
680+
if (mUnityNotificationManager == null || mUnityNotificationManager.mOpenActivity == null) {
681+
openActivity = UnityNotificationUtilities.getOpenAppActivity(context, true);
694682
}
683+
else {
684+
openActivity = mUnityNotificationManager.mOpenActivity;
685+
}
686+
687+
id = builder.getExtras().getInt(KEY_ID, -1);
688+
notif = buildNotificationForSending(context, openActivity, builder);
689+
}
690+
691+
if (notif != null) {
692+
UnityNotificationManager.notify(context, id, notif);
695693
}
696-
} catch (BadParcelableException e) {
697-
Log.w(TAG_UNITY, e.toString());
698694
}
699695
}
700696

0 commit comments

Comments
 (0)