Title: File Sync Mobile App Post by: Stefan S. on August 15, 2017, 11:43:59 am Hello,
for a new Mobile Project I am looking for a way to sync Files between Mobile-Device and Server within a backgroud Process The sync-Process should start without any user Action on the Mobile Device. So I create some files on the device and if there is a internet connetion these files should send to the server. I did something like that with "OwnCloud" but this is not really what I want to do now, because I don't want to install any additional Software. On Server side I have a running GAS. So I can use a http WebService or I can use "runOnServer" on the mobile Device. But what is the best way to run this in Background on the mobile Device? Have I to use "on idle" or "on timer" Has anyone did something like that before? Any help is welome. Kind regard Stefan S. Title: Re: File Sync Mobile App Post by: Reuben B. on August 15, 2017, 02:09:28 pm Quote But what is the best way to run this in Background on the mobile Device? I would like to be proven wrong, but my understanding is that what you are after, running in the background on the mobile device can't be done. The reason being that the Genero Mobile application is effectively single threaded and so whilst the fglrun process is handing the GUI side of the app, you can't have another fglrun process running in the background doing the file transfer.Note: how RUN is listed in the limitations. http://4js.com/online_documentation/fjs-fgl-manual-html/#c_fgl_mobile_bdl_limitations.html So this means you can't have something like this to sync silently every 60 seconds... Code
This is how I figure most news apps work. Periodically check to see if any new articles and if so download them in the background whilst you continue to read the current article. With this limitation you are pushed down the path of having an explicit action to manage the sync e.g. Code
... and the user having started the sync has to wait for the sync to finish. I have wondered in the past if you could do something like this ... Code
... where the API you are using is responsible for making sure each transmission is very small, small enough so that it does not interrupt the users UI experience (less than a second). So you would have to split files into small sizes, send each piece individually, and join them back together at the other end. How small depends on your network capability. I have not tried to implement this concept to see if it can practically be done. Reuben Title: Re: File Sync Mobile App Post by: Leo S. on August 15, 2017, 10:57:13 pm Hi Stefan, currently I can't recommend an "out of the box" solution.
The most promising path are the upcoming Cordova Plugin integration tools and all cordova plugins which offer "background" upload/download capabilities. Namely this plugin https://github.com/spoonconsulting/cordova-plugin-background-upload and this plugin https://github.com/sgrebnov/cordova-plugin-background-download/blob/master/src/ios/BackgroundDownload.m are plugins dealing under IOS with the "NSURLSession" API https://developer.apple.com/documentation/foundation/nsurlsession?language=objc which ensures upload/download "out of process" by the system networking daemon. So regardless if your GMI process is in the foreground or background using this API ensures that uploads/downloads continue. I can't estimate if on Android the same happens (need to ask my GMA colleague) For the download plugin I already made a sample for GMI 1.30.06 (Are you in the 3.10 Genero-EAP ?) downloadable from https://www.generomobile.de/gmi/cdvdownload.zip For the upload I need to check if the upload plugin is already usable in GMI. If none of the plugins are fitting your purpose then there is also the possibility adding a custom frontcall in GMI/GMA using the appropriate system APIs . This could be done already for the released GM 1.20. I can only warn to use ON IDLE 1 to do networks syncs. 1. this will make you unhappy because this needs to be implanted in each possible DIALOG the user enters and will hence lead to code pollution. 2. If you are in INPUT statements you may run into focus and validation issues (reminder: ON IDLE flushes the current field, if you are in an INTEGER field and type accidentally "a" then you get an unwanted validation error and your end users will be irritated) 3. It won't work anyway if your app is a longer time in the background (at least on IOS). As mentioned my comments are pretty IOS centric, but I guess the Android answer will be similar Regards, Leo |