`
zani
  • 浏览: 356183 次
  • 性别: Icon_minigender_1
  • 来自: 福州
社区版块
存档分类
最新评论

app running in background

 
阅读更多

app需满足下面条件才能在后台运行,否则最多只能在后台10~15分钟

your app must be one of these types:

  • Apps that play audible content to the user while in the background, such as a music player app
  • Apps that keep users informed of their location at all times, such as a navigation app
  • Apps that support Voice over Internet Protocol (VoIP)
  • Newsstand apps that need to download and process new content
  • Apps that receive regular updates from external accessories

And you must add to the Info.plist as follows: Add the UIBackgroundModes key to your Info.plist file and set its value to an array containing one or more of the following strings:

  • audio—The app plays audible content to the user while in the background. (This content includes streaming audio or video content using AirPlay.)
  • location—The app keeps users informed of their location, even while it is running in the background.
  • voip—The app provides the ability for the user to make phone calls using an Internet connection.
  • newsstand-content—The app is aNewsstand app that downloads and processesmagazine or newspaper content in the background.
  • external-accessory—The app works with a hardware accessory that needs to deliver updates on a regular schedule through the External Accessory framework.
  • bluetooth-central—The app works with a Bluetooth accessory that needs to deliver updates on a regular schedule through the CoreBluetooth framework

Note that part of the review process will be checking to make sure that your app does what it says it's doing with regard to background processing.

 

 

--不能满足上面3个条件的app后台运行例子----------------------------

UIApplication*    app = [UIApplication sharedApplication];
 __block UIBackgroundTaskIdentifier  task = [app beginBackgroundTaskWithExpirationHandler:^{
        [app endBackgroundTask:task];
        task = UIBackgroundTaskInvalid;
    }];
// Start the long-running task and return immediately.
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

        // Do the work associated with the task.
        NSLog(@"Started background task timeremaining = %f", [app backgroundTimeRemaining]);
        if (connectedToNetwork) {
            // do work son...
        }

        [app endBackgroundTask:task];
        task = UIBackgroundTaskInvalid;
    });
 

 

分享到:
评论

相关推荐

    Android代码-process-explorer-app

    node.js-based process in the background that listens to a socket connection. By pointing your computer's web browser to that socket on the device -- say using "adb forward" -- you can see all the ...

    Examples-pcap_socket_dsp_TheNeed_

    a WinForm application) may need to respond to a hotkey or shortcut (used interchangeably in this article) regardless of if the app is focused or running in the background.

    ios App programging

    Length Tasks`)、下载内容(`Downloading Content in the Background`)、实施长时间运行任务(`Implementing Long-Running Tasks`)、声明应用支持的后台任务(`Declaring Your App’s Supported Background Tasks...

    DigitalEyewear-7-0-50

    The Stereo Rendering sample for Java will show you how to detect whether your app is running on a digital eyewear device, and how to then configure its video background rendering for stereo....

    Programming Windows Store Apps with C#

    Implement functionality for running tasks in the background Table of Contents Chapter 1. Making the Transition from .NET (Part 1) Chapter 2. Making the Transition from .NET (Part 2) Chapter 3. Local ...

    Beginning iOS Programming: Building and Deploying iOS Applications

    Author Nick Harris has extensive experience developing for iOS and provides a solid background for teaching the building blocks of app development. Learn Objective-C and how it differs from other ...

    The.Busy.Coders.Guide.to.Android.Development.Version.8.3.epub

    That’s where this book comes in Spanning 466 pages, The Busy Coder’s Guide to Android Development covers a wide range of Android capabilities and APIs, from creating simple user interfaces, to ...

    BobBuilder_app

    These tests were done on a HP ML120G6 system with 12Gb Ram, 10k raid disk drives running Windows 2008 Server R2 64 bit. For a measure of relative performance to RaptorDb v1 I have included a 20 ...

    [iOS] iOS 编程入门经典 英文版

    Building and Deploying iOS Applications starts at the beginning including an introduction to Objective C and gives you the skills you need to get your apps up and running Author Nick Harris has ...

    Windows Runtime via C#

    compress, and encrypt data via streams Design apps that give the illusion of running using live tiles, background transfers, and background tasks Share data between apps using the clipboard and the ...

    iOS 8 Swift Programming Cookbook Solutions Examples for iOS Apps.pdf

    For multitasking, they can use background modes and task completion to manage app behavior when running in the background. - **Sample Code**: The book includes code examples for implementing ...

    Delphi Cookbook Third Edition

    You will learn how to import Java and Objective C libraries in your app and how to use the SDK classes from your Object Pascal code. Chapter 10, Delphi and IoT, talks about how the two most popular ...

    CommonsWare.The.Busy.Coders.Guide.to.Android.Development.Version.8.2.2017

    That’s where this book comes in Spanning 466 pages, The Busy Coder’s Guide to Android Development covers a wide range of Android capabilities and APIs, from creating simple user interfaces, to ...

    Android 监听应用前/后台切换实例代码

    - TRIM_MEMORY_BACKGROUND:应用正在后台运行,但系统正在释放内存。 - TRIM_MEMORY_UI_HIDDEN:应用从前台切换到后台,用户界面被隐藏。 在本文提供的实例中,开发者可以通过覆盖onTrimMemory(int level)方法来...

    VB编程资源大全(英文源码 API)

    <END><br>64,TransIco.zip An update to my previous code : Added a couple of features some ppl asked me for...like the ability to change the text colour of the icon and also keep the background ...

    win 3.11 for workgroup tcpip支持

    DHCP will (in the background) continue to try to acquire a valid lease while Windows for Workgroups continues to run (although you will not have TCP/IP functionality). If you are running with DHCP ...

    针对安卓8.0对后台服务的限制,对Service做出了兼容的框架

    .setContentText("Your app is performing background tasks.") .setSmallIcon(R.drawable.ic_notification) .build(); startForeground(1, notification); } ``` 其次,对于那些不必要立即执行或可以稍后执行...

Global site tag (gtag.js) - Google Analytics