Skip to content

Commit 68b4743

Browse files
committed
Make getting manager thread-safe and possible when only having context
1 parent a7e6208 commit 68b4743

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,17 @@ private void initialize(Activity activity) {
107107
mBackgroundThread.start();
108108
}
109109

110-
public static UnityNotificationManager getNotificationManagerImpl(Context context) {
111-
return getNotificationManagerImpl(context, (Activity) context);
110+
public static synchronized UnityNotificationManager getNotificationManagerImpl(Context context) {
111+
if (mUnityNotificationManager == null) {
112+
mUnityNotificationManager = new UnityNotificationManager();
113+
}
114+
115+
mUnityNotificationManager.mContext = context.getApplicationContext();
116+
return mUnityNotificationManager;
112117
}
113118

114119
// Called from managed code.
115-
public static UnityNotificationManager getNotificationManagerImpl(Context context, Activity activity) {
120+
public static synchronized UnityNotificationManager getNotificationManagerImpl(Context context, Activity activity) {
116121
if (mUnityNotificationManager == null) {
117122
mUnityNotificationManager = new UnityNotificationManager();
118123
}

0 commit comments

Comments
 (0)