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

App is not closing after clicking on the notification when app is in foreground #7

Closed anishmishra0 closed 3 weeks ago

anishmishra0 commented 1 month ago

Here's screen recording of the issue https://github.com/user-attachments/assets/33045044-b290-4b0c-aa1f-21040257f801

cengiz-pz commented 1 month ago

Hi @anishmishra0, could you share your code as well as what you wanted to achieve? Thanks.

anishmishra0 commented 1 month ago
extends Control

var id = 0

func _ready():
    if !$NotificationScheduler.has_post_notifications_permission():
        $NotificationScheduler.request_post_notifications_permission()
        var channel = NotificationChannel.new()
        channel.set_id("my_channel_id")
        channel.set_name("My Channel Name")
        channel.set_description("My channel description")
        channel.set_importance(NotificationChannel.Importance.HIGH)
        $NotificationScheduler.create_notification_channel(channel)

func _on_button_pressed():
    var my_notification_data = NotificationData.new()
    id +=1
    my_notification_data.set_id(id)
    my_notification_data.set_channel_id("my_channel_id")
    my_notification_data.set_title("My Notification Title")
    my_notification_data.set_content("notification content "+str(id))
    my_notification_data.set_delay(int($LineEdit.text))

    $NotificationScheduler.schedule(my_notification_data)

func _on_button_2_pressed():
    var my_notification_data = NotificationData.new()
    my_notification_data.set_id(30)
    my_notification_data.set_channel_id("my_channel_id")
    my_notification_data.set_title("repeating")
    my_notification_data.set_content("repeating content ")
    my_notification_data.set_small_icon_name("ic_notification")
    my_notification_data.set_delay(int($LineEdit.text))
    my_notification_data.set_interval(30)

    $NotificationScheduler.schedule(my_notification_data)

My Scene Screenshot 2024-07-31 172024

anishmishra0 commented 1 month ago

what you wanted to achieve?

I Just want to close the app, it keeps on restarting when i try to close it with back button

Steps to reproduce

  1. Schedule a notification and wait for it to trigger
  2. Click on the notification when it pops in status bar ( note: app is still open in foreground)
  3. After that try to close the app with back button
cengiz-pz commented 1 month ago

It sounds like when you tap the back button, Android restarts the activity that forwarded the notification to your app, which forwards the notification to your app again. Interesting bug. Thanks for reporting it.

cengiz-pz commented 3 weeks ago

Hi @anishmishra0, please let me know if the new release fixes this issue on your side.

anishmishra0 commented 3 weeks ago

Yes, this new release resolved my issue. Thank you very much for this plugin.

cengiz-pz commented 3 weeks ago

You're welcome. Also check out the other plugins.