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

Initializing from main doesn't trigger onSelectNotification when terminated #372

Closed
quangduy-luong opened this issue Nov 18, 2019 · 2 comments

Comments

@quangduy-luong
Copy link

Describe the bug
The onSelectNotificationCallback is not being triggered when the app is launched from terminated state using the new initialization approach from the example app.

To Reproduce

  1. Launch the example app
  2. Display a notification
  3. Close the app by swiping up
  4. Tap on the notification

Expected behavior
The app should launch and navigate the user to the second screen.

This is fixed if I move the initialization code back to the first StatefulWidget's initState.

@MaikuB
Copy link
Owner

MaikuB commented Nov 18, 2019

D'oh! Many thanks for catching that as I forgot to test that scenario. I won't get to push an update today but if you intend to initialise in the main please try the following

  • call WidgetsFlutterBinding.ensureInitialized(); in your main function
  • switch from StreamController to BehaviourSubject from rxdart package

Let me know if this works for you. Worked fine for me

@quangduy-luong
Copy link
Author

Works like a charm! Thanks, I'll be closing for now then.

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