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

Click on Notification, OneSignal.Notifications.addClickListener does not listen when app is background state. [Issue faced flutter 3.24.1] #945

Open
1 task done
istiaksaif opened this issue Sep 3, 2024 · 5 comments

Comments

@istiaksaif
Copy link

istiaksaif commented Sep 3, 2024

Unable to listen addClickListener. previous flutter version worked

print('------- init'); #/this line print when app open
print('------- listen'); #//but this line not print

Future<void> oneSignalInitial() async {
    await notificationPermissions();
    String oneSignalAppId = '9e2fd62d-65e4-................';

    OneSignal.Debug.setLogLevel(OSLogLevel.verbose);
    OneSignal.Debug.setAlertLevel(OSLogLevel.none);
    OneSignal.consentRequired(false);
    OneSignal.Notifications.addPermissionObserver((state) {
      print("Has permission $state");
    });

    OneSignal.initialize(oneSignalAppId);
    OneSignal.LiveActivities.setupDefault();
    OneSignal.Notifications.addForegroundWillDisplayListener((event) {
      event.preventDefault();
      event.notification.display();
      _handleForegroundNotification(event.notification);
    });

    OneSignal.User.pushSubscription.addObserver((state) async {
      if (OneSignal.User.pushSubscription.id!=null){
        AppPref.setValue('fcmToken', OneSignal.User.pushSubscription.id!);
      }
    });
    print('------- init');
    OneSignal.Notifications.addClickListener((notification) async {
      print('------- listen');
      var additionalData = notification.notification.additionalData;
      if (additionalData != null) {
        var type = additionalData["type"];
        if (type == "calling") {
          _handleCallNotificationClick(additionalData);
        }
      }
    });

  }

Code of Conduct

  • I agree to follow this project's Code of Conduct
@istiaksaif istiaksaif changed the title Click on Notification, OneSignal.Notifications.addClickListener does not listen when app is background & not running state Click on Notification, OneSignal.Notifications.addClickListener does not listen when app is background & not running state. [Issue faced flutter 3.24.1] Sep 3, 2024
@istiaksaif istiaksaif changed the title Click on Notification, OneSignal.Notifications.addClickListener does not listen when app is background & not running state. [Issue faced flutter 3.24.1] Click on Notification, OneSignal.Notifications.addClickListener does not listen when app is background state. [Issue faced flutter 3.24.1] Sep 3, 2024
@octav8us
Copy link

got the same problem here, any workarounds?

@nandaprasesoft98
Copy link

I'm also faced this issue, any solution please?

@AmorApp
Copy link

AmorApp commented Oct 1, 2024

Also facing the same issue

1 similar comment
@fandofastest
Copy link

Also facing the same issue

@nan-li
Copy link
Contributor

nan-li commented Nov 4, 2024

Hi @istiaksaif

What version of the OneSignal Flutter SDK are you using?

Which platform(s) are affected?

  • iOS
  • Android

Additionally, the app is in a backgrounded and not killed state?

Where are you calling oneSignalInitial() from?

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

No branches or pull requests

6 participants