问题
I have smartphone app for Android and iOS. I have data syncronization going on with server. I want to send some data to server when app is closed, for example last activities of user. I know how to do it if app is opened again. In some situations users phone is in offline mode, no network connection is available. So data gets stored in apps local database. User closes app and no data is synced. Later on network connection returns.
So my main question. Is it possible to queue syncronization with server when app is closed, but network connection is available? Like as soon as network connection returns, phone sends data to server.
I'm using hybrid framework Ionic. My data in app is stored in SQLite.
回答1:
There are no app close event available. What you can use would be a platform pause
event.
constructor( private platform: Platform ) {
platform.ready().then(() => {
this.platform.pause.subscribe(() => {
console.log('[INFO] App paused');
});
});
}
来源:https://stackoverflow.com/questions/41383080/sync-data-with-server-when-app-is-closed