Ios implements unlimited background tasks, and ios implements background tasks.

Source: Internet
Author: User

Ios implements unlimited background tasks, and ios implements background tasks.

Requirement

Our app uses the heartbeat mechanism to maintain the user's login status so that we can receive messages and commands sent from the server, however, when the app enters the background for about 3 minutes or 10 minutes, the app will be suspended by the system, and the user will time out and go offline, so that the app must run in the background for a long time.

Cause

An app is generally running, in the background, or suspended on the frontend. When you press the home or screen lock key, the app will run on the background. According to Apple's official explanation, apple allows the app to run in the background for a short period of time and perform some processing. It takes about 10 minutes. After 10 minutes, the app is forcibly suspended by the system and all operations and threads are suspended, the thread is started only when the user clicks to enter this app.

Solution

1. Wireless playing of music in the app Background, Background Audio

2. Location Services

3. Background voice service and voip

4. automatically download and update newspapers and magazines in the background, Newsstand

.....

Implementation

I am using background positioning. This is the simplest method. After testing, users are online all morning, but my apps are enterprise-level applications that do not need to be launched, this solution may fail Apple's review.

Introduce header files

# Import <CoreLocation/CoreLocation. h>

Add a variable in AppDelegate. m.

@ Property (nonatomic, strong) CLLocationManager * locationManager;

Create an instance after the app is started and set the proxy

Self. locationManager = [[CLLocationManager alloc] init];

Self. locationManager. delegate = self;

After the app enters the background, it continues to locate

[Self. locationManager startUpdatingLocation];

 

Related Article

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.