DrMoriarty / godot-local-notification

Godot module for local notifications (android and iOS)
MIT License
140 stars 24 forks source link

Android trouble? #31

Closed rondlite closed 2 years ago

rondlite commented 2 years ago

What seems to be the problem on Android since it works like a charm ! You need POST_NOTIFICATIONS set as custom permission.. or is it just with the daily?

yan88a commented 2 years ago

seems android 12 changed its notification management system so once you try to use the current one - the project crashes..

Kontrano commented 2 years ago

Is there currently an issue wtih Notifications or does everything still work?

yan88a commented 2 years ago

Hey @Kontrano , yep, compiling on godot 3.5 for target sdk 31 (android) wont work for me.. at firs it used to crash.. after adding the following permissions: android.permission.SCHEDULE_EXACT_ALARM android.permission.USE_EXACT_ALARM app wont crash. but notifications wont work. any ideas?

Kontrano commented 2 years ago

Not currently but i need to get it working for an app im working on aswell, so ill try tinkering over the coming week if i can get it to work somehow

rondlite commented 2 years ago

This is the problem currently:

FATAL EXCEPTION: GLThread 42
Process: com.***.***, PID: 20544
java.lang.IllegalArgumentException: com.***.***: 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.showLocalNotification(LocalNotification.java:92)
    at org.godotengine.godot.GodotLib.step(Native Method)
    at org.godotengine.godot.GodotRenderer.onDrawFrame(GodotRenderer.java:59)
    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)

It is a change in SDK requirements, FLAG_MUTABLE, has to become FLAG_IMMUTABLE

Kontrano commented 2 years ago

So do we need to do anything? or will it actually just work? I'm not exactly following (I haven't actually started working with it yet)

yan88a commented 2 years ago

@Kontrano - wont work for me... note that you need to add the permissions i mentioned above as well to avoid crash

yan88a commented 2 years ago

@Kontrano played with it a bit & looks like it works.. you can use this one - https://github.com/yan88a/godot-local-notification

Kontrano commented 2 years ago

Nice, This works for Android 12 then as well?

yan88a commented 2 years ago

looks ok didnt do any in depth testing but managed not to crash & get notification

Kontrano commented 2 years ago

Nice ill do some testing in the coming week aswell and let you know

Kontrano commented 2 years ago

@yan88a Btw, do you have a way to show the notifications while the app is out of focus or in the background?

rondlite commented 2 years ago

You set the time in minutes and it will show no matter if the app is in memory or not

Op zo 16 okt. 2022 01:09 schreef Kontrano @.***>:

@yan88a https://github.com/yan88a Btw, do you have a way to show the notifications while the app is out of focus or in the background?

— Reply to this email directly, view it on GitHub https://github.com/DrMoriarty/godot-local-notification/issues/31#issuecomment-1279848566, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4F2TTGK2RKUZB2J7FPNQDWDM2SPANCNFSM6AAAAAAQEG52WE . You are receiving this because you authored the thread.Message ID: @.***>

Kontrano commented 2 years ago

You set the time in minutes and it will show no matter if the app is in memory or not Op zo 16 okt. 2022 01:09 schreef Kontrano @.>: @yan88a https://github.com/yan88a Btw, do you have a way to show the notifications while the app is out of focus or in the background? — Reply to this email directly, view it on GitHub <#31 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4F2TTGK2RKUZB2J7FPNQDWDM2SPANCNFSM6AAAAAAQEG52WE . You are receiving this because you authored the thread.Message ID: @.>

Could you give my an example? since im not fully following unless you mean the interval in the show command? show(message: String, title: String, interval: float, tag: int, repeating_interval: int = 0)

yan88a commented 2 years ago

@Kontrano it should work that way since you register the notification into android. but, it seems i have some bugs 1st - app icon shown weird 2nd - notification wont show outside the app...

will poke it a bit this week...

rondlite commented 2 years ago

Could you give my an example? since im not fully following unless you mean the interval in the show command?

Yes the interval in the show command, for instance I set it to 24 hours (in seconds) as soon as I give a user the daily award. This way the next day a notification is shown reminding user to come back to the app

rondlite commented 2 years ago

Seems this issue is being fixed #32, so this one is double ...