Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

How to handle on resume in Vue? Non-firebase messaging only #1460

Closed
curtiscarlson opened this issue Nov 3, 2019 · 3 comments
Closed

How to handle on resume in Vue? Non-firebase messaging only #1460

curtiscarlson opened this issue Nov 3, 2019 · 3 comments

Comments

@curtiscarlson
Copy link

curtiscarlson commented Nov 3, 2019

I don't think this is a bug but I haven't seen this documented anywhere. I am trying to handle a notification. In Ios, the problem is when the app is not running at all and a notification comes in, and is "tapped". The app simply goes to the home screen. In Android, the same thing happens, but even when the app is in background mode. I have seen fixes for this in angular, but I'm not sure if I understand how to implement this in nativescript-vue. The combination of these two technologies is rendering my searches somewhat useless.

My guess is that I need the onMessageReceived callback to attach the data to something in my vue model, I'm just not sure what. Then I need to access this on resume, but I don't get how?

Just looking for someone who maybe has figured this out to let me in on the secrets? Hopefully this thread helps others, too. Thanks.

@curtiscarlson
Copy link
Author

I have dug into this further. Everything is working and onMessageReceived is running, but vue.$navigateTo has no effect in this state (app is closed and notification is tapped). I have tried this inside of both created() and mounted() and it doesn't make a difference. But if I wrap the navigateTo in a timeout, it works. So it seems to have to do with firebase running onMessageReceived before vue is ready for it to. Is there a fix for this?

@EddyVerbruggen
Copy link
Owner

Perhaps this is better asked in the nativescript-vue repo as it's more about the Vue lifecycle related to an iOS appdelegate event rather than specific to this plugin (and I don't have the answer).

@curtiscarlson
Copy link
Author

curtiscarlson commented Nov 5, 2019

You are correct. I was not sure if it was a race condition between the two technologies though. I got iOS working last night by solving the race condition, but the fix doesn't make "sense" to me.... I moved all of the firebase stuff into a hook that runs when the app is more fully loaded and it solved it. But it doesn't make sense really....only the onMessageReceived was affected - and it is running after the app re-launches, not when the message is received, so it's hard to understand what's "happening" behind the scenes. I was going to close this myself once I solved android because I am not convinced it is the same issue, and not sure if there is an issue or not yet. I will report back, thank you @EddyVerbruggen

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants