Skip to content

Commit 4b61f2c

Browse files
committed
Forward onReceive to the primary instance
1 parent ffefed8 commit 4b61f2c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,10 @@ public void cancelAllNotifications() {
651651

652652
@Override
653653
public void onReceive(Context context, Intent intent) {
654+
getNotificationManagerImpl(context).onReceive(intent);
655+
}
656+
657+
public void onReceive(Intent intent) {
654658
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
655659
if (KEY_NOTIFICATION_DISMISSED.equals(intent.getAction())) {
656660
int removedId = intent.getIntExtra(KEY_NOTIFICATION_DISMISSED, -1);
@@ -660,7 +664,7 @@ public void onReceive(Context context, Intent intent) {
660664
return;
661665
}
662666
}
663-
Object notification = getNotificationOrBuilderForIntent(context, intent);
667+
Object notification = getNotificationOrBuilderForIntent(mContext, intent);
664668
if (notification != null) {
665669
Notification notif = null;
666670
int id = -1;
@@ -677,19 +681,19 @@ public void onReceive(Context context, Intent intent) {
677681
}
678682

679683
Class openActivity;
680-
if (mUnityNotificationManager == null || mUnityNotificationManager.mOpenActivity == null) {
681-
openActivity = UnityNotificationUtilities.getOpenAppActivity(context, true);
684+
if (mOpenActivity == null) {
685+
openActivity = UnityNotificationUtilities.getOpenAppActivity(mContext, true);
682686
}
683687
else {
684-
openActivity = mUnityNotificationManager.mOpenActivity;
688+
openActivity = mOpenActivity;
685689
}
686690

687691
id = builder.getExtras().getInt(KEY_ID, -1);
688-
notif = buildNotificationForSending(context, openActivity, builder);
692+
notif = buildNotificationForSending(mContext, openActivity, builder);
689693
}
690694

691695
if (notif != null) {
692-
UnityNotificationManager.notify(context, id, notif);
696+
UnityNotificationManager.notify(mContext, id, notif);
693697
}
694698
}
695699
}

0 commit comments

Comments
 (0)