IOS Background Unlimited tasks

Source: Internet
Author: User

Find some code about the iOS background where you can continue to perform tasks, share:


First, you need to configure the Info-plist file, create a new required background modes inside. This is an array, where the following is added:

APP provides Voice over IP services (VOIP)

APP plays audio or streams audio/video using AirPlay (audio)

APP processes Newsstand Kit downloads (newsstand-content)

APP communicates using Corebluetooth ( bluetooth-central )

APP shares data using Corebluetooth ( bluetooth-peripheral )

APP Registers for location updates

After adding, add the following code in-(void) Applicationdidenterbackground: (uiapplication *) application

  1. __block Uibackgroundtaskidentifier Background_task;
  2. Background_task = [Application beginbackgroundtaskwithexpirationhandler:^ {
  3. [Application Endbackgroundtask:background_task];
  4. Background_task  =  Uibackgroundtaskinvalid  ;
  5. }];
  6. Dispatch_async (Dispatch_get_global_queue (dispatch_queue_priority_default, 0), ^{
  7. while (TRUE)
  8. {
  9. [Nsthread sleepfortimeinterval:1];
  10. Writing execution Task code
  11. }
  12. [Application Endbackgroundtask:background_task];
  13. Background_task  =  Uibackgroundtaskinvalid  ;
  14. });

IOS Background Unlimited tasks

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.