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

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

Open
1 task done
tazy-dev opened this issue Feb 19, 2025 · 7 comments
Open
1 task done

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

tazy-dev opened this issue Feb 19, 2025 · 7 comments

Comments

@tazy-dev
Copy link

tazy-dev commented Feb 19, 2025

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

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

nan-li commented Feb 19, 2025

Hi @tazy-dev thanks for reporting. The app should open from a notification click in the terminated state.

Can you try this without the Notification Click Listener?

I wonder if the click listener is affecting this.

@tazy-dev
Copy link
Author

tazy-dev commented Feb 20, 2025

Will try it,
@nan-li
For navigation to a specific page opun clicking the notification
My initial guess
As seen in the code that IAM passing a context to the function the setup the listener , som maybe it waiting for the context to be available
Like the first click wake the app the second click works normally
And do you recommend using navigator key in this case Instead of the actual context

@nan-li
Copy link
Contributor

nan-li commented Feb 21, 2025

Hi @tazy-dev, I won't be able to help you much with your own app navigation process.

We should first narrow down if this is a OneSignal SDK issue that OneSignal can help with, or if this is an issue with the navigation logic within the click listener.

Let me know what you experience if you remove the click listener.

@tazy-dev
Copy link
Author

@nan-li yes it's regarding notification onclick , when the app is in terminated state
the app won't open upon clicking the notification for the first time

@guillaumeboussion
Copy link

guillaumeboussion commented Feb 25, 2025

Hello @tazy-dev, we encountered the same issue and opened an issue on the Android repo (see here) which has been fixed few hours ago (didn't test it yet)

@nan-li when are you planning to bump the android dependency ?

@tazy-dev
Copy link
Author

@guillaumeboussion
I am new to this
It said that it was fixed
But what I need to do in order to get the changes in my app (noob question 🫡)

@guillaumeboussion
Copy link

@tazy-dev as the OneSignal Flutter SDK relies on the native OneSignal Android SDK, we need to wait for the Flutter team to update the internal dependency on Android. Feel free to send a DM if you need more assistance

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

3 participants