Ios - Is it possible to start a background thread even the app is disabled

I have an application, it will remind the user at a specific time. Now I want to sync data from the server every 60 minutes (or other duration: 1 day, 1 week, ... in the future). It should be running, even the app is already disabled.

I've also heard many different answers, but most of them are: "iOS does not allow the developer to create a background thread." Can anyone help me confirm this?

If we cannot make a background thread, does it have any other solutions to solve the problem?

I look forward to any response from anyone!

Thanks Ryan

+3


source to share


4 answers


If you just need to periodically notify the user, local notifications can indeed be scheduled and are fairly easy to implement. If you need to really update your content take a look at the background selection: https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html



+1


source


It's not exactly what you're looking for, but see the iOS App Programming Guide: Background execution , specifically fetching small sums Contents Opportunistic section:



Optimizing the receipt of small amounts of content

Applications that periodically check for new content can ask the system to wake them up so that they can initiate a fetch operation for that content. To support this mode, enable the Background option fetch

in the Background Modes section of the Features tab in your Xcode project. (You can also enable this support by enabling the UIBackgroundModes

fetch value key in your application Info.plist

.) Enabling this mode does not guarantee that the system will present your application at any time to perform background settings. The system must balance your applications to receive content with the needs of other applications and the system itself. After evaluating this information, the system gives time to applications when there are good opportunities to do so.

When a good opportunity arises, the system wakes up or runs your application in the background and calls the application delegateapplication:performFetchWithCompletionHandler:

... Use this method to check for new content and initiate a download operation if the content is available. Once you've finished loading the new content, you must execute the provided completion handler block, passing in a result that indicates whether the content is available. Executing this block tells the system that it can move your application back to a suspended state and evaluate its energy use. Apps that load small amounts of content quickly and accurately reflect when they have content available for download are more likely to have a runtime in the future than apps that take a long time to load their content or that application content was available. but then don't download anything.

When uploading any content, it is recommended to use a class NSURLSession

to start and manage uploads For information on how to use this class to manage upload and download tasks, see the URL URL Programming Guide .

+1


source


you can schedule a local notification to remind the user, but as in Android, you cannot perform background maintenance.

0


source


You've got it backwards. The application, if it is not working, cannot wake up to check the server. But the server can transmit data to the application and wake it up - this is what push notifications (remote notifications) are:

https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/WhatAreRemoteNotif.html#//apple_ref/doc/uid/TP40008194-CH102-SW1

So click on the app when you want to sync it.

0


source







All Articles