Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixs pending Intent issue on Godot 3.5 #32

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

finepointcgi
Copy link

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.

@finepointcgi
Copy link
Author

Pause merging this im looking into a small bug.

@rondlite rondlite mentioned this pull request Oct 18, 2022
@rondlite
Copy link

what is the status of this PR ?

@yan88a
Copy link

yan88a commented Oct 21, 2022

@rondlite in general looks like the pushes work
but only when app is running / bg.
this was the case for my branch as well...

@Kontrano
Copy link

Kontrano commented Oct 23, 2022

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)

@Kontrano
Copy link

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.

@yan88a
Copy link

yan88a commented Oct 24, 2022

@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..

@Kontrano
Copy link

@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.

@yan88a
Copy link

yan88a commented Oct 24, 2022

@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

@Kontrano
Copy link

@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 :)

@yan88a
Copy link

yan88a commented Oct 29, 2022

@Kontrano hey,
try using this aar.
works for me..
LocalNotification.debug.zip

@finepointcgi
Copy link
Author

finepointcgi commented Oct 29, 2022

@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.

@yan88a
Copy link

yan88a commented Oct 29, 2022

@finepointcgi - all is your doing :)
I recompiled it with new build tools & permissions
thats it..

@Kontrano
Copy link

@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.

@finepointcgi
Copy link
Author

finepointcgi commented Nov 3, 2022

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

@kyoz
Copy link
Contributor

kyoz commented Nov 7, 2022

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

LocalNotification.zip

@finepointcgi
Copy link
Author

finepointcgi commented Dec 23, 2022

This should be good to merge also thank you @kyoz for the help i have updated it

@rzuf79
Copy link

rzuf79 commented Jan 11, 2023

Thank you so much guys, you just saved a life! :D

@BriBarthelemy
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants