Reactions to "Add Background Data Refresh to Your iOS Apps" blog post RRS feed

  • Question

  • User130334 posted


    (poke @MikeJames I guess ) I would like to comment on a blog post that came out about a month ago: Add Background Data Refresh to Your iOS Apps

    I think the blog post forgets about a pretty strong limitation in Background Fetch: Your application will be killed after 30 seconds if the code in PerformFetch doesn't return faster than that. Now, 30 seconds could seem like a long time but if you start making network requests time flies rather quickly. You will start with one network request and it will work pretty well in most cases. But then you will feel the need to add more requests, or your sync logic will get more complicated, then you will start having problems. So I think the design exposed in the blog post is a dangerous design to begin with as it may bring you many problems in the future. Unless your HTTP client is using Background Sessions introduced in iOS7. But I don't think that the provided HttpClient does that?

    That would be interesting to have a blog post or recipe about how to integrate Background Sessions in a Xamarin.Forms app with dependency injection.

    I would also like to take the opportunity to cast some light on this question that remains unanswered about how we can test Background Fetch on iOS simulator.

    Thursday, April 7, 2016 1:54 PM

All replies

  • User2418 posted

    I believe if you use ModernHttp, then under the hood ModernHttp uses NSUrlSession.

    Thursday, April 7, 2016 2:23 PM
  • User130334 posted

    @GavinGrant said: I believe if you use ModernHttp, then under the hood ModernHttp uses NSUrlSession.

    Ok, interesting, I'll have a look at that. But does ModernHttp use Background NSUrlSessions and handle callbacks from iOS? There are different types of NSUrlSession, Background sessions is only one of them.

    Thursday, April 7, 2016 2:26 PM
  • User2418 posted

    No idea, I've not used it myself personally.

    What about wrapping the calls around BeginBackgroundTask / EndBackgroundTask.

    Thursday, April 7, 2016 2:37 PM