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

[Bug]: Push Notifications Not Opening App When Closed #993

Open
3 tasks done
bahadirkalay opened this issue Feb 3, 2025 · 1 comment
Open
3 tasks done

[Bug]: Push Notifications Not Opening App When Closed #993

bahadirkalay opened this issue Feb 3, 2025 · 1 comment

Comments

@bahadirkalay
Copy link

bahadirkalay commented Feb 3, 2025

Description:
I am experiencing an issue with push notifications in my Flutter application. When the app is closed, tapping on a push notification does not open the app or navigate to the specified page. Here are the details:
Platform:Andoid, IOS
Flutter Version: 3.19.0
OneSignal SDK Version: 5.1.2
Expected Behavior: When a push notification is tapped, the app should open and navigate to the specified route or page.
Actual Behavior: Tapping on a push notification does not open the app when it is closed.

 void _handleNotificationClick(OSNotificationClickEvent event) async {
    String? deepLink = event.notification.launchUrl;
    String? route = event.notification.additionalData?['route'];
    if (deepLink != null && deepLink.isNotEmpty) {
      Uri url = Uri.parse(deepLink);
      if (await canLaunchUrl(url)) {
        await launchUrl(url, mode: LaunchMode.externalApplication);
      }
    } else if (route != null && route.isNotEmpty) {
      if (navigatorKey.currentState != null) {
        navigatorKey.currentState?.pushNamed(route);
      }
    }
  }

Steps to reproduce?

1:Close the app completely.
2:Send a push notification with a deep link or route.
3:Tap on the notification.
4:Observe that the app does not open or navigate to the intended page.

What did you expect to happen?

I expected the app to open and navigate to the specified page when I tap on a push notification, even if the app is closed.

OneSignal Flutter SDK version

5.1.2

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct
@nan-li
Copy link
Contributor

nan-li commented Feb 11, 2025

Hi @bahadirkalay, is this an issue with the push notification and OneSignal SDK, or is this an issue with your custom navigation?

If you don't use this _handleNotificationClick method, and click on a notification with or without a launch URL, does your app open?

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

2 participants