Satyajeet Gupta
Satyajeet Gupta

Reputation: 1

Background threads ends automatically after 3 minutes in xamarin iOS

Whenever I am creating any thread to run in background for any application it stops automatically after 3 minutes. I am using Xamarin forms for building the iOS application. The issue exists only with the iOS and is working fine with other platforms. Below here is the code that I used to create the background thread:

nint taskID = UIKit.UIApplication.SharedApplication.BeginBackgroundTask( () => {Task.Factory.StartNew (() => syncData ());});

I have tried enabling the background mode and background fetch attributes in info.plist but using these could not solve the issue.

Please suggest me for the above issue.

Upvotes: 0

Views: 364

Answers (1)

Taier
Taier

Reputation: 2119

Background tasks from iOS7 will only give you 180 seconds. If your app not specified as "Music player/GPS navigation" and etc. As I understand from your code, you want to use background tasks for sync. For that background fetch works perfectly. You can find a good tutorial here - https://developer.xamarin.com/guides/ios/application_fundamentals/backgrounding/part_3_ios_backgrounding_techniques/updating_an_application_in_the_background/

Upvotes: 1

Related Questions