Hello guys.
Currently I’m trying to make a feature that check the Notification permission status (Allow, not allow,…) by making a native plugin on android.
private static final String LOGTAG = "UnityU";
private Context context;
public NotificationStatusChecker(Context context) {
this.context = context;
}
public boolean areNotificationsEnabled() {
boolean result = NotificationManagerCompat.from(this.context).areNotificationsEnabled();
Log.i(LOGTAG, "Notifications enabled :: " + result);
return result;
}
public static boolean areNotificationsEnabledFromContext(Context customContext) {
boolean result = NotificationManagerCompat.from(customContext).areNotificationsEnabled();
Log.i(LOGTAG, "From custom context notifications enabled :: " + result);
return result;
}
Those above are my code from this thread
But I keep getting this error from blank project, what can I do?
2021-09-22 15:11:41.550 24069-8421/? E/Unity: AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/NotificationManagerCompat;
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/NotificationManagerCompat;
at ftech.plugin.unity.NotificationStatusChecker.areNotificationsEnabled(NotificationStatusChecker.java:20)
at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source:72)
at android.os.MessageQueue.next(MessageQueue.java:404)
at android.os.Looper.loop(Looper.java:206)
at com.unity3d.player.UnityPlayer$e.run(Unknown Source:32)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.app.NotificationManagerCompat" on path: DexPathList[[zip file "/data/app/~~Io9vCKuyx0nvVM_OJ04_rg==/ftech.vn.unity-Y5GsG9bnUHDMrgubc8vB6Q==/base.apk"],nativeLibraryDirectories=[/data/app/~~Io9vCKuyx0nvVM_OJ04_rg==/ftech.vn.unity-Y5GsG9bnUHDMrgubc8vB6Q==/lib/arm, /data/