Store Firebase data locally on phone

Hi, I need to get records from Firebase and store them locally in my Ionic 3 app such that every time I open the app, it checks Firebase for changes and updates the local one if need be. It needs to be listening for changes even when the app is closed. Kinda like an email app (when you open an email app, all the previous messages are already there - no need to redownload from the server - and is updated when new messages arrive).

Right now, every time I load the app, it pulls fresh data from Firebase, and when I navigate to a different page and return, it does a fresh pull of data. I’d rather it get all the data one time and store locally, only updating when there’s a change. It should also be listening to Firebase for changes.

How do I achieve that?