Skip to content

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

Open
@bahadirkalay

Description

@bahadirkalay

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions