0

I have been looking all over the place and I could not find a solution for my issue and this could be because I am coming from Android Development to iOS and backgrounding in both platforms is different.

So I have a service in my android app which runs a code doing so much stuff (Push/Pull database, downloading images from Azure Blobs, displays progress in the status bar etc even when the app is closed) - I am trying to do something similar in iOS and I got few options such as

  • Background-Safe Tasks
  • DidEnterBackground Tasks
  • Background Transfers (iOS 7+)

So initially thought Background Transfers is the best option as it does not have the time limit and it still runs if the app is closed by user and will notify the APP in AppDelegate once it finishes.

https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/backgrounding/ios-backgrounding-techniques/ios-backgrounding-with-tasks#background-transfers

Digging further I fingered that with Background Transfer although they don't have time limits etc, they can only do two things such as Upload or Download file using session.CreateUploadTask (request) and session.CreateDownloadTask (request) respectively.

  • Upload Tasks
  • Download Tasks

https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/backgrounding/ios-backgrounding-walkthroughs/background-transfer-walkthrough#working-with-tasks-and-delegates

Where my requirement is to run a piece of code and not only download files as my code is doing way more than just downloading images.

I also looked at this to get my head around but made me lost (iOS equivalent to Android Service?)

I have no idea what to do, Any help will be appreciated.

Cheers

Ali
  • 2,702
  • 3
  • 32
  • 54
  • 1
    As stated in SO Q/A that you linked in your question, there just is no equivalate in iOS. If the app is not in the foreground you are restricted in terms of background tasks, I would focus on `PerformFetch` to download those Azure blobs and Remote Push Notifications to data updates to the local db... and if the user kills the app, those fetchs will not happen until they relaunch it... – SushiHangover Jul 18 '18 at 10:39
  • @aliusman are you getting any error while executing code in bg? – Satish Mavani Jul 18 '18 at 11:49
  • @SatishMavani No, I don't get any errors (I am still trying to figure out what approach I should be using moving to iOS) – Ali Jul 20 '18 at 00:31

0 Answers0