-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
SelectNotification callback before showing first screen #99
Comments
couldn't you just check if Navigator.canPop(context) returns false and if it does then you could use pushReplacement or pushAndRemoveUntil? If you weren't on the root page when the app has already been opened and the navigation stack isn't empty then it should return true |
That would be possible if the root page is always the same otherwise logic gets more complicated, also if there are form elements on it which might be filled out already. |
I'm not sure there's a way around it at the moment with the flow of when things get executed on the platform side too. One thought I've had that may or may not work is to expose a method through the plugin that you could call in the main function to determine if the app is being launched due to a notification, you'd use the result of that to change the home page (https://docs.flutter.io/flutter/material/MaterialApp/home.html). initState can't be async but I believe main can be |
I've release a new version of the plugin (0.3.8) that adds a |
Awesome, works great! Tested it both on iOS and Android. |
The didNotificationLaunchApp flag once set to true always remains true, it breaks my other flows |
@onimeshc-iprogrammer it is only meant to stay true within the same app session if a notification launched the app but not if it's been restarted. If that is still the same scenario you're referring to then this is working as intended and you'll need to resolve within your own app as it's a method to query the launch state |
Is there any way to reset the flag programmatically? |
No and there are no plans to. You'll need to fix the logic in your own app, which I would guess is calling the method multiple times |
Let me understand, I have all my routes been set using the router, when I launch the app from notification after being killed I get the flag as true, which is fine, later when my app is in active/minimised state I yet get the flag as true. And please can I get about what method do I need to call multiple times? |
Yes that is expected, it's still the same app session. Launching is about if the app was started where before then it not running at all i.e. being in the background doesn't count as it was just suspended.
Sorry but I don't understanding what you mean as the wording doesn't make sense. Can you rephrase? If you mean how to stop calling the same method, you could track some state in your own app to make sure it only happens once |
@MaikuB Is it possible to not open the app while onSelectNotification callback is triggered as usual? |
No |
Is it possible to somehow get the callback before showing the root page? Basically to determine which page to load. I've tried a bunch of things but could not get it to work so far.
In my case I would like to show a different page as root if the app gets newly started via a notification callback. I can't just do pushReplacment or pushAndRemoveUntil inside the active root page since I wanna preserve the stack in case the app has been opened before the callback.
The text was updated successfully, but these errors were encountered: