Sample for background data fetching

Hi,

Like i wrote in the “Run in Background” thread i work on an app, which should check in intervalls if there is new data.

The app should also do this when it’s in the background, nice would be if the app could send a notification also on the lock screen. Currently the app check with with the xojo.Core.Timer with JSON if new data arrives, but this work only if the app is in the foreground active.

Someone has a working sample, I’m also willing to pay something for this.

Wouldn’t that be a case for a NSURLSession? I created most of the classes for iOSLib, but they are fully untested, undocumented and probably buggy. Let me know if you think this could be a solution.

I don’t think apple will let you check for updates like this because of the constant battery drain. Instead you should have your service send the app a push notification when new data is available. Unfortunately this isn’t working quite right in Xojo because of entitlement issues (see <https://xojo.com/issue/41579>) but there hasn’t been any progress on fixing this.

[quote=239726:@Jason King]I don’t think apple will let you check for updates like this because of the constant battery drain.[/quote]It is doable, but one has to follow the guidelines from Apple rather accurately: Background Execution.

yes, that’s what I meant. Not running a permanent fetch but have a URLSession start a background action from time to time which may wake up the app. I’ll have a look into the classes I have so far the next days. Don’t remember what I implemented. I started to write them for a project which was then delayed, so I put them aside.

Yes, a NSURLSession could do it, would be great to have a working example.

A push notification would be and nicer, if it the problems are fixed one time.

Never objecting about a better thing replacing a workable solution! I’ll update the classes soon and inform you.

I’ll update the classes soon and inform you

You found time to update the classes already?

Thx

So Marcel, I read your post when I was traveling and forgot to reply in time. Sorry again: The answer is yes and no. I updated a lot of things but when I tried to set up a demo view, a WooCommerce update forced me to rework another project first so that the customer can use it again. I’ll continue next week and inform you once I got the first demo steps working. From then on, I would need your feedback on what is still missing. There’s so many classes I am not sure which will be necessary for the majority of cases yet.