Sync data with server when app is closed

纵然是瞬间 提交于 2019-12-12 01:52:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!