OneSignal-Flutter-SDK icon indicating copy to clipboard operation
OneSignal-Flutter-SDK copied to clipboard

[question]: Setup Notification to open The app from terminal state

Open tazy-dev opened this issue 9 months ago • 14 comments
trafficstars

How can we help?

I Searched the docs bit Found Nothing , i want to setup my service such that upon clicking on notification it opens the app, so Far working on fore/back ground states but when the app is in terminated state Clicking the notification does nothing and i need to click it one or 2 more times

My Setup

initOneSignal() {
  OneSignal.Debug.setLogLevel(
    OSLogLevel.error,
  );

  OneSignal.initialize (AppConstants.oneSignalAppID);
  OneSignal.Notifications.requestPermission(true);
}

setupNotification(BuildContext context) {
  OneSignal.Notifications.addClickListener((openedResult) {
      PodcastEntity podcastEntity = PodcastModel.fromJson(
        jsonDecode(
          openedResult.notification.additionalData!["podcast"],
        ),
      ).toEntity;
      context.read<NotificationBloc>().add(
            NotificationClickedEvent(
              entity: podcastEntity,
            ),
          );
    });
}

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

tazy-dev avatar Feb 19 '25 23:02 tazy-dev