How to set up iOS background run

Source: Internet
Author: User

There are two ways to keep your program running in the background:

1. Direct: (When the background memory is not there, the system will terminate the background running, that is, the time is uncertain, this way is poor like the background to apply for background running requirements, is a very poor way!! )

2. Configure the Plist file: Declare your app type in Info.plist to audio, play in the background mp3 (there are five ways, do not repeat here, only audio as an example, the rest of the basic similar)

2.1>>>>

Add the audio value in Uibackgroundmodes to register the background audio app. This value allows the application to use a listening background, such as music playback or audio streaming applications, in the background. For applications that support audio and video capabilities, you can also add this value to ensure that you can continue running the flow continuously.

When the audio value is set, when your application enters the background, the system's multimedia frame automatically prevents it from being hung up, but if the application stops playing audio or video, the system hangs up the application.

When your application is in the background, you can perform arbitrary system audio frames to initialize the background audio. Your application should restrict itself in the background so that it executes work-related code and cannot perform any tasks unrelated to the content being played.

Because there are multiple applications that support audio, the foreground application always allows audio playback, and the background application is allowed to play some audio content, depending on the setting of the audio Session object. Applications should always set their audio session object and handle other types of audio-related notifications and interrupts with care. See Audio Session Programming Guide.

Then enter Autio in the next step

The above settings are generally OK here is worth mentioning is that sometimes we do chat tools or news media, but also need to run the background, but when we set up the Autio, the system in memory tense when we do not play audio playback, this time, the background will give our program to terminate the operation, The following combination of the second method, introduced to everyone a little trick is to play a OKB in the background audio, infinite loop playback, so that the words do not affect the foreground operation of our program, but also ensure that the background unlimited operation (the previous period of time to extract the Sina Weibo file package, found that there is a 0kb of audio, This is how Sina Weibo is estimated to be used.

How to set up iOS background run

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.