one question, that I’m thinking about for a long time now and didn’t find a good solution for, yet.
I’m using Ionic 2 and firebase as backend. I want to implement a function that sets a flag to true if the user is logged in to a certain wifi network (his home wifi). Otherwise the flag is to be set false. This flag needs to be stored at firebase database (not just local storage). It is important that the flag is permanently updated when the network connection changes and even if the app is running in background.
I thought about using the Native Network Plugin and it’s “onchange()” method. However, this may not be a proper approach.
For example: The user is logged in at his home wifi and the flag, hence, is set to ‘true’. Let’s assume, he disconnects from the wifi, but doesn’t have a mobile connection. Then the app knows, that he disconnected from the wifi, but the flag in the database cannot be updated as there is no connection to the internet.
So this will probably be the wrong approach and I would have to set up something like a ping that is sent from the server (Firebase) to check if the client is still active in the certain network??
What would you suggest here? Any idea and any help would be appreciated.
Important: The flag needs to be updated in all cases, even if the app is running in background!