First determine if multithreading is supported
Uidevice *device == NO; if ([Device respondstoselector: @selector (ismultitasksupported)]) { = device.mulltitaskingsupported;}
Declare the Uibackgroundmodes key value that you want to add to the background task Info.plist.
It contains one or more string values, including audio: provides sound playback functionality in the background, including sound streaming and video playback;
Location: In the background you can keep the user's position information
VoIP: Use each value in front of the VoIP feature in the background to let the system know that your application should be awakened at the appropriate time.
For example, an application that starts playing music and then moves to the background still requires execution time to fill the audio output buffer. Adding the audio key is used to tell the system frame that it needs to resume playback and can callback the application at the appropriate time interval, and if the application does not include this, any audio playback will stop running after moving to the background. In addition to the method of adding key values, iOS provides two ways to make your application work in the background:
The task completion-application can request additional time from the system to complete a given task
Local notifications-applications can schedule time to perform local notifications delivery for long background tasks: Applications can request to run in the background for special services. These applications do not run continuously, but are awakened by the system framework at the right time to implement these services
iOS development How to run the program in the background