godot-local-notification
godot-local-notification copied to clipboard
Fixs pending Intent issue on Godot 3.5
Fixes this specific bug Exception java.lang.IllegalArgumentException: org.godotengine.sweepit: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. at android.app.PendingIntent.checkFlags (PendingIntent.java:375) at android.app.PendingIntent.getBroadcastAsUser (PendingIntent.java:645) at android.app.PendingIntent.getBroadcast (PendingIntent.java:632) at ru.mobilap.localnotification.LocalNotification.getPendingIntent (LocalNotification.java:147) at ru.mobilap.localnotification.LocalNotification.cancelLocalNotification (LocalNotification.java:125) at org.godotengine.godot.GodotLib.step at org.godotengine.godot.GodotRenderer.onDrawFrame (GodotRenderer.java:57) at org.godotengine.godot.gl.GLSurfaceView$GLThread.guardedRun (GLSurfaceView.java:1576) at org.godotengine.godot.gl.GLSurfaceView$GLThread.run (GLSurfaceView.java:1278)
let me know if theres anything I need to change.
Pause merging this im looking into a small bug.
what is the status of this PR ?
@rondlite in general looks like the pushes work but only when app is running / bg. this was the case for my branch as well...
Hi all, Could someone potentially explain to me how I would implement this fix for my current project? I can't install this via NativeLib since it hasn't been merged as far as I know so I'm pretty lost on how to continue from here. Any help is much appreciated :)
Edit: I think i got it, if i replace the .aar file in the android/plugins folder with the one from your release (please correct me if I'm wrong)
Hi all, Could someone potentially explain to me how I would implement this fix for my current project? I can't install this via NativeLib since it hasn't been merged as far as I know so I'm pretty lost on how to continue from here. Any help is much appreciated :)
Edit: I think i got it, if i replace the .aar file in the android/plugins folder with the one from your release (please correct me if I'm wrong)
No crashes but also no notifications in Android 12, On Android 10 it all works as intended.
@Kontrano hi, try this branch: https://github.com/yan88a/godot-local-notification i recompiled it with updated gradle tools & permissions. make sure you add custom permissions in the godot editor as well:
- android.permission.SCHEDULE_EXACT_ALARM
- android.permission.USE_EXACT_ALARM
- android.permission.POST_NOTIFICATIONS for me - wont crash, and works as expected.
in case you debug it on a device you previously ran a problematic version - android will block your notification request as "bad process" you can verify it in logcat. you will need to re install it.. (or try other device) this is the case when you may not get a configured notification..
@yan88a I would love to, but I am not sure how to accomplish that. Could you potentially give me an overview of the steps that I need to do to accomplish this? I would be very thankful. Btw I'm using the Nativlib GUI implementation if that matters.
@Kontrano I won't be near my pc in the next few days. You managed to download the fork in my comment above? As for the permissions- in the android export screen, scroll down to the permission section. It starts with the ability to add custom ones. Expand the array to 3. Them paste in the 3 I mentioned in my previous comment. That should do the trick. I guess by now you tried a lot of versions on your test device. Installing a valid version to an app with bad history will cause android to cancel this activity. Try uninstalling the app from the settings screen and reboot your device (worked for my s21) Or even better - try Installing it to a new one.
Hope it helps.
If you still have trouble, I can try and send you the aar around the weekend
@yan88a I was missing the last permission "android.permission.POST_NOTIFICATIONS" so at least that's one step forward but I still couldn't get it to work.
Currently, I am using the .aar file from @finepointcgi that he has in the latest release on his fork but I'm thinking this may not include the latest fix. since I have no clue on how to build this (I have since figured out that this is somehow done via android studio I think)
So I've added all 3 permissions and am using the .aar file I mentioned above. I have now also tested it on 1 physical android 12 device and 3 emulated ones, following the uninstall and restart process for the physical one and making new virtual devices for the emulated ones. It worked on none of them sadly. I also tried an emulated android 10 device and it worked like a charm again.
So I'm guessing its something wrong with the .aar file. So if you could send me yours I would be very grateful :)
@Kontrano hey, try using this aar. works for me.. LocalNotification.debug.zip
@yan88a Was there any changes to the code in my pr for it to work for you? If not ill check my release and see whats going on..
Edit: I miss read the thead! If you fixed it I can drop this pr and have you just throw one in.
@finepointcgi - all is your doing :) I recompiled it with new build tools & permissions thats it..
@Kontrano hey, try using this aar. works for me.. LocalNotification.debug.zip
@yan88a Thanks a lot this one works like a charm.so far no issues other than that the notifications don't have the logo on android 12 but thats a minor thing. Again thanks to you both and everyone who makes and maintains these vital plugins.
Ive updated with some of the stuff discussed here. Should be good to merge now.
Drafted a release https://github.com/finepointcgi/godot-local-notification/releases/tag/v0.2.4
Hi @finepointcgi , Thank you very much for the pr. It should work but I do think we should keep FLAG_UPDATE_CURRENT. Without it, when user click on the notification to open the game, it may not display the notification messages or even can crash on some devices.
Like so
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
Also, the Pending intent in LocalNotificationReceiver.java
also need to update.
Here i'v tested and recompile for anyone who is in rush :D
This should be good to merge also thank you @kyoz for the help i have updated it
Thank you so much guys, you just saved a life! :D
Hello,
I've tried to add the module with the @kyoz zip file. and I don't have error except this when I try to send a locale notification:
"Unable to launch app org.godotengine.localnotificationandroid/10162 for broadcast Intent { flg=0x10 cmp=org.godotengine.localnotificationandroid/ru.mobilap.localnotification.LocalNotificationReceiver (has extras) }: process is bad"
In the meantime, I've tried to install the source code, but I'm not able to compile. Do you think this module could be use? Or not a good idea with Godot 3.5 and I should migrate to Godot 4 ? (but it seems that Godot 4.x with c# is still experimental.
Can you help me?