Skip to content

Commit a49b88c

Browse files
committed
Add helper for obtaining fields
1 parent cdf317e commit a49b88c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55

66
#if UNITY_2022_2_OR_NEWER
77
using JniMethodID = System.IntPtr;
8+
using JniFieldID = System.IntPtr;
89
#else
910
using JniMethodID = System.String;
11+
using JniFieldID = System.String;
1012
#endif
1113

1214
namespace Unity.Notifications.Android
@@ -473,6 +475,18 @@ public JniApi(AndroidJavaClass notificationManagerClass, AndroidJavaObject notif
473475
Bundle.CollectJni();
474476
}
475477

478+
public static JniFieldID FindField(AndroidJavaClass clazz, string name, string signature, bool isStatic)
479+
{
480+
#if UNITY_2022_2_OR_NEWER
481+
var field = AndroidJNIHelper.GetFieldID(clazz.GetRawClass(), name, signature, isStatic);
482+
if (field == IntPtr.Zero)
483+
throw new Exception($"Field {name} with signature {signature} not found");
484+
return field;
485+
#else
486+
return name;
487+
#endif
488+
}
489+
476490
public static JniMethodID FindMethod(AndroidJavaClass clazz, string name, string signature, bool isStatic)
477491
{
478492
#if UNITY_2022_2_OR_NEWER

0 commit comments

Comments
 (0)