cengiz-pz / godot-android-notification-scheduler-plugin

Notification Scheduler Plugin allows scheduling of local notifications on the Android platform.
MIT License
21 stars 4 forks source link

Notification is not working when app is closed on Xiaomi Android #4

Open anishmishra0 opened 3 months ago

anishmishra0 commented 3 months ago

Notification is working properly when app is in foreground or background but it is not working when app is closed using swipe up from recents screen. When i again start the app then all the pending notification and shown

cengiz-pz commented 3 months ago

Hi @codingfever-anishmishra, I couldn't reproduce your issue using the demo app. Could you please send me an ordered list of steps needed to reproduce the issue? (Maybe I'm missing a step)

anishmishra0 commented 3 months ago

Thanks For your Reply @cengiz-pz Steps to reproduce:-

  1. Scheduled Notification (I did for 5 second)
  2. Then immediately turned off app using Recents Screen (swipe up app from recents screen)
  3. Waited for more than a minute but notification didn't arrived.
  4. Opened app and now notification arrived.

Note: sometimes even after opening the app, notification didn't arrived. And even if I reschedule new notification nothing happens.

anishmishra0 commented 3 months ago

i used adb logcat and I think this is the problem because whenever notification is not arrived, i am getting this

05-18 08:48:18.299  2452  2544 D ProcessStarter: proc frequent died! proc =
org.codingfeaver.demonotification:godot_notification_receiver callerPkg = org.codingfeaver.demonotification

Take a look at this

05-18 08:48:15.380 2452 2563 I ProcessSceneCleaner: SwipeUpClean: kill procName=org.codingfeaver.demonotification info=AS:90519 05-18 08:48:15.380 2452 2563 I ActivityManager: Killing 28867:org.codingfeaver.demonotification/u0a268 (adj 905): SwipeUpClean 05-18 08:48:15.382 2452 2563 I ProcessSceneCleaner: SwipeUpClean: kill procName=org.codingfeaver.demonotification:godot_notification_receiver info=AS:90519 05-18 08:48:15.382 2452 2563 I ActivityManager: Killing 28965:org.codingfeaver.demonotification:godot_notification_receiver/u0a268 (adj 905): SwipeUpClean 05-18 08:48:15.464 2452 2927 I WindowManager: WIN DEATH: Window{a74d71f u0 org.codingfeaver.demonotification/com.godot.game.GodotApp} 05-18 08:48:15.466 2452 2927 W InputManager-JNI: Input channel object 'a74d71f org.codingfeaver.demonotification/com.godot.game.GodotApp (client)' was disposed without first being removed with the input manager! 05-18 08:48:15.513 2452 2641 W UsageStatsService: Unexpected activity event reported! (org.codingfeaver.demonotification/com.godot.game.GodotApp event : 23 instanceId : 266481878) 05-18 08:48:18.299 2452 2544 D ProcessStarter: proc frequent died! proc = org.codingfeaver.demonotification:godot_notification_receiver callerPkg = org.codingfeaver.demonotification 05-18 08:48:18.306 2452 2452 D AlarmManager: mPendingIntent -> PendingIntent{436a57b: PendingIntentRecord{1ae0e27 org.codingfeaver.demonotification broadcastIntent}}

Here's the screen recording of the problem. https://github.com/cengiz-pz/godot-android-notification-scheduler-plugin/assets/64732159/3d252725-d009-4f99-8861-fa93a7629ac8

cengiz-pz commented 3 months ago

@codingfever-anishmishra, it sounds like your device is force-stopping your application when you swipe up from recent apps screen. Some devices from Xiaomi, Asus, and others do this to reduce power consumption. There should be a way to configure your device to work normally, without force stopping.

anishmishra0 commented 3 months ago

@cengiz-pz yeah I am using a Xiaomi Device. So, can't this problem be solved in plugin??

cengiz-pz commented 3 months ago

I am using a Xiaomi Device. So, can't this problem be solved in plugin??

Xiaomi and others have modified the normal behavior of Android OS to improve the performance statistics for their devices at the cost of user experience. There is a way to workaround this by using the new Device Administration API, but that would be an overkill and work only on Android 14+ devices. I am not aware of any other solutions, but will keep looking.

mcdz commented 1 month ago

Try changing battery optimization and battery restrictions to see if that fixes the issue. If that works, the workaround would be to ask user to disable battery optimisation for this app. But, it's not really a fix. I'll look into it. Please try reproducing the issue with battery optimization disabled and then also try with no restrictions.

Also, it could be something related to allowing app to run in background.

anishmishra0 commented 1 month ago

I'll look into it. Please try reproducing the issue with battery optimization disabled and then also try with no restrictions.

I tried with no restriction but the problem still exists.(And I cannot find any option for battery optimization)

Edit: After setting it to no restriction, sometimes i do get the notification. Note: like i previously said the issue only happens if i remove the application from recents screen and logcat prints something like

2452 2544 D ProcessStarter: proc frequent died! proc = org.codingfeaver.demonotification:godot_notification_receiver callerPkg = org.codingfeaver.demonotification