About iOS background issues (i) (iOS background refresh, background location, background download, real backstage)

Source: Internet
Author: User

About the background of iOS, the following references some paragraphs to do a bit of brain repair, please students to look roughly, there is a basis, the original source

-----------------------------------------------------------------------------------------------

OS 7, in fact, the app has four background mode, regardless of what kind of background mechanism, all need to take advantage of Apple to give the corresponding background interface implementation. IOS7 system, developers can flexibly use a variety of background interface (API) to achieve more intelligent application operations.
Oneno background push only
The first is the traditional no background operation, only Apple push mechanism, this method appears in iOS 3.x most of the system version. In this way, the app will close the exit when the home button is pressed, and its data is transferred via an apple-built push server and does not need to be run in the app's background. The reason this is not very good is that after each launch, re-entry will need to reload, although the push can be unified to resolve the data and information transmission, but encountered the need to enter the application frequently (such as chat app) will appear bad experience.
Twotombstone Style
The second way is the tombstone background mechanism, which is used extensively after iOS 4, which is what people call pseudo-multitasking. The first improvement in this way is that when you press the home key to the main interface, the app goes into the background, but it freezes and doesn't do anything.
ThreeSmart Dispatch Backend
The third is the background of the system intelligent Dispatch, IOS 7 new background fetch, this background interface is mentioned on Apple WWDC 2013, it will automatically adjust according to user behavior to achieve the most efficient back-end mode, able to deal with not very timely information acquisition. For example, some background information updates for social and news applications, the iOS system intelligently assigns background acquisition frequency and startup time for each app based on the frequency, time, and current network and battery status of the app.
Since the data background refresh operation of the application with this interface is uniformly dispatched, the system can obtain data from multiple applications in one process, similar to the unified push mechanism, so as to maximize the power saving. However, this method also has a disadvantage, that is, the developer can not set the date when the data is updated, so this background method can only be used in some time-sensitive and low-sensitivity places.
FourReal Backstage
The fourth way is the real back-end mechanism, but the real background of iOS and Android background mechanism is not the same, in order to balance the system experience and unified process management, iOS added a lot of restrictions on this. There are several background interface modes that are roughly the following:
1, Background Audio, this is the background of the sound, this is very early, but also the most used iOS device background application, call this interface can achieve background music playback.
2, location Services, which is the background of positioning, the system will have a unified page to manage.
3, VoIP, background voice service, similar to the Skype call application needs to call, can make voice calls in the background.
4, Newsstand, newspapers and magazines in the background automatically download updates, which can be automatically updated in real-time.
5, Background Task completion, this interface as early as iOS 4, it can be used by any type of app, but in the old system, the interface of the background limit run time is only 10 minutes, meaning that when the application back to the background, its background run only to last 10 Minutes will go to hibernation. IOS 7 has made a change to this interface, the original is 10 minutes in a row, that is, regardless of whether the user in 10 minutes to turn off the screen into hibernation, the app will still wait in the background for 10 minutes after the end of the launch, and the new improvement is that if you encounter a shutdown of the screen hibernation, the background running 10 minutes will be followed , the remaining background time will be counted until the user wakes the device again. This way the background is still running for 10 minutes, but not continuously, and the advantage of doing so is to save power.
If there are some dictionary applications with the background copy of the word selection function, in fact, it is the use of this interface, if the user opened the dictionary and launched, even if the screen is closed, but the dictionary is still running in the background, the power consumption is relatively large, on iOS 7, this problem can be resolved.
6, Remote Notification, this is the larger one of the improved interface, the past chat-type application to accept the push after the point in need to collect information, this situation in QQ, and other applications are most obvious. However, with this interface, the situation will no longer exist, and later push will be able to start the background task directly. It is worth noting that the remote notification supports silent notification (silent push), so Dropbox such synchronization applications can be in the background in the most energy-saving mode of real-time silent synchronization, similar to the cloth card comics This can also push the chase of the diffuse Draw a new chapter and silently download in the background, until the download good to send users a local push, users click to see no need to Network
7, Background Transfer Service, background upload download. iOS is closest to a traditional multi-tasking backend interface that can be called by any type of app without time constraints. Application scenarios include background uploading and downloading data, which makes it possible to update the data package in the background, upload video in the background, and so on, but as its name can only be used to handle the task of uploading and downloading such a transmission class, it is powerless to monitor such a background-like clipboard.

--------------------------------------------------------------------------------------------------------------- -----------------

The following is an introduction to the actual operation

First we select Gapability in the project, find back ground mode,

We'll refresh the location updates for example.

When we initialize Cllocationmanager, we need to add such a code

// the mode is to resist iOS in the background Kill program settings, iOS will automatically turn off background refresh of some applications based on current phone usage, the statement declares that it cannot be paused, but does not necessarily force the end of app refresh in the event of poor performance of the iOS system

After testing, the Cllocationmanager protocol method can be called in the background, at this time the app is relatively power consumption, if the background has other processing and computing needs, it is best to update the position triggered by multi-threaded processing, preferably multi-threaded queue processing. Another way is to reduce the threshold of Cllocationmanager in the life cycle function of the appdelegate when it is about to enter the background, for example, the meter level of the original monitoring, can reduce the thousands of meters

Join in the Applicationdidenterbackground

if ([Cllocationmanager significantlocationchangemonitoringavailable])         {[                    [Mapcenter manager] stopupdatinglocation];            [[Mapcenter Manage] startmonitoringsignificantlocationchanges];        }         Else          {            NSLog (@ "significant location change monitoring are notavailable. " );        }


Join in the Applicationdidbecomeactive

     if ([Cllocationmanager significantlocationchangemonitoringavailable])     {[[Mapcenter Manager] stopmonitoringsignificantlocationchanges]; [[Mapcenter Manager] startupdatinglocation];} Else      {NSLog (@ "significant location change monitoring are notavailable. " );}

About iOS background issues (i) (iOS background refresh, background location, background download, real backstage)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.