Skip to content

Commit a5c2f85

Browse files
committed
Make getNotificationFromIntent instance method
1 parent 2eeae60 commit a5c2f85

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

com.unity.mobile.notifications/Runtime/Android/AndroidNotificationCenter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public NotificationManagerJni(AndroidJavaClass clazz, AndroidJavaObject obj)
106106

107107
void CollectMethods(AndroidJavaClass clazz)
108108
{
109-
getNotificationFromIntent = JniApi.FindMethod(clazz, "getNotificationFromIntent", "(Landroid/content/Context;Landroid/content/Intent;)Landroid/app/Notification;", true);
109+
getNotificationFromIntent = JniApi.FindMethod(clazz, "getNotificationFromIntent", "(Landroid/content/Intent;)Landroid/app/Notification;", false);
110110
setNotificationIcon = JniApi.FindMethod(clazz, "setNotificationIcon", "(Landroid/app/Notification$Builder;Ljava/lang/String;Ljava/lang/String;)V", true);
111111
setNotificationColor = JniApi.FindMethod(clazz, "setNotificationColor", "(Landroid/app/Notification$Builder;I)V", true);
112112
getNotificationColor = JniApi.FindMethod(clazz, "getNotificationColor", "(Landroid/app/Notification;)Ljava/lang/Integer;", true);
@@ -118,9 +118,9 @@ void CollectMethods(AndroidJavaClass clazz)
118118
createNotificationBuilder = JniApi.FindMethod(clazz, "createNotificationBuilder", "(Ljava/lang/String;)Landroid/app/Notification$Builder;", false);
119119
}
120120

121-
public AndroidJavaObject GetNotificationFromIntent(AndroidJavaObject activity, AndroidJavaObject intent)
121+
public AndroidJavaObject GetNotificationFromIntent(AndroidJavaObject intent)
122122
{
123-
return klass.CallStatic<AndroidJavaObject>(getNotificationFromIntent, activity, intent);
123+
return self.Call<AndroidJavaObject>(getNotificationFromIntent, intent);
124124
}
125125

126126
public void SetNotificationIcon(AndroidJavaObject builder, AndroidJavaObject keyName, string icon)
@@ -839,7 +839,7 @@ public static AndroidNotificationIntentData GetLastNotificationIntent()
839839
return null;
840840

841841
var intent = s_CurrentActivity.Call<AndroidJavaObject>("getIntent");
842-
var notification = s_Jni.NotificationManager.GetNotificationFromIntent(s_CurrentActivity, intent);
842+
var notification = s_Jni.NotificationManager.GetNotificationFromIntent(intent);
843843
if (notification == null)
844844
return null;
845845
return GetNotificationData(notification);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -840,11 +840,11 @@ private static boolean isInForeground() {
840840
return (appProcessInfo.importance == IMPORTANCE_FOREGROUND || appProcessInfo.importance == IMPORTANCE_VISIBLE);
841841
}
842842

843-
public static Notification getNotificationFromIntent(Context context, Intent intent) {
843+
public Notification getNotificationFromIntent(Intent intent) {
844844
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
845845
if (intent.hasExtra(KEY_NOTIFICATION_ID)) {
846846
int id = intent.getExtras().getInt(KEY_NOTIFICATION_ID);
847-
StatusBarNotification[] shownNotifications = getNotificationManager(context).getActiveNotifications();
847+
StatusBarNotification[] shownNotifications = getNotificationManager().getActiveNotifications();
848848
for (StatusBarNotification n : shownNotifications) {
849849
if (n.getId() == id) {
850850
return n.getNotification();
@@ -853,7 +853,7 @@ public static Notification getNotificationFromIntent(Context context, Intent int
853853
}
854854
}
855855

856-
Object notification = getNotificationOrBuilderForIntent(context, intent);
856+
Object notification = getNotificationOrBuilderForIntent(mContext, intent);
857857
if (notification == null)
858858
return null;
859859
if (notification instanceof Notification)

0 commit comments

Comments
 (0)