Repeating Local Notification called from Unity - using Android Plugin not working
I'm trying to make a Unity app that will show a notification every day even if the app is closed. Right now I've create a plugin that does just this.
But when I put this plugin in Unity and try it out, the application closes unexpectedly just when it is about to enter the Notification Builder portion of the plugin code (I've debugged the code to the point that I know this is the issue).
Thing is, I see no issue with the Notification Builder, or the content within it.
I've searched here and tried to update my JDK, SDK and my Unity application but no result!
Any example of a plugin that is used by and called from Unity, to show a Notification on Android?
Here's the code:
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel("default", "YOUR_CHANNEL_NAME", NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription("YOUR_NOTIFICATION_CHANNEL_DESCRIPTION");
mNotificationManager.createNotificationChannel(channel);
}
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, "default")
.setSmallIcon(res.getIdentifier("smallicon", "drawable", context.getPackageName())) // notification icon
.setContentTitle("bla2") // title for notification
.setContentText("bla")// message for notification
.setAutoCancel(true); // clear notification after click
Intent intent2 = new Intent(context, unityActivityClass);
PendingIntent pi = PendingIntent.getActivity(context, 0, intent2, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(pi);
mNotificationManager.notify(0, mBuilder.build());
Your answer
Follow this Question
Related Questions
creating plugin for android 0 Answers
JAVA_HOME environment references a directory 1 Answer
fingerprintjs integration / NoClassDefFoundException 0 Answers
adMob ads are black 2 Answers
How to get the low level rendering plugin working on Android? 1 Answer