when my iphone receiving calls, and my app is in background, i want call some codes (alert coreblue4.0 device) - iphone

I have used ctcallcenter, and use beginBackgroundTaskWithExpirationHandler, so I have only 10 minutes to call my codes. How can I make it longer,the app proxBLE have achieved it?

From the Apple documentation, you can extend the execution time only in the below cases. In order to do that, you need to add the UIBackgroundModes key to info.plist file. See the detailed explanation below.
Implementing Long-Running Background Tasks
For tasks that require more execution time to implement, you must request specific permissions to run them in the background without their being suspended. In iOS, only specific app types are allowed to run in the background:
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
Apps that implement these services must declare the services they support and use system frameworks to implement the relevant aspects of those services. Declaring the services lets the system know which services you use, but in some cases it is the system frameworks that actually prevent your application from being suspended.
Declaring Your App’s Supported Background Tasks
Support for some types of background execution must be declared in advance by the app that uses them. An app declares support for a service using its Info.plist file. 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 a Newsstand app that downloads and processes magazine 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 Core Bluetooth framework.
bluetooth-peripheral—The app supports Bluetooth communication in peripheral mode through the Core Bluetooth framework.
Each of the preceding values lets the system know that your app should be woken up at appropriate times to respond to relevant events. For example, an app that begins playing music and then moves to the background still needs execution time to fill the audio output buffers. Including the audio key tells the system frameworks that they should continue playing and make the necessary callbacks to the app at appropriate intervals. If the app does not include this key, any audio being played by the app stops when the app moves to the background.

Related

How to specify that app must perform important tasks in the background?

I'm making an app that needs to run in the background. It plays online radio and at the same time must perform calculations.
I know there is a background expiration handler but it is very limited in time to my knowledge. Is there a way an app can perform calculations in the background for a very long time?
Someone mentioned something about specifying your app needs navigation and then it can keep doing important things. How?
From the Apple documentation:
Implementing Long-Running Background Tasks
For tasks that require more execution time to implement, you must
request specific permissions to run them in the background without
their being suspended. In iOS, only specific app types are allowed to
run in the background:
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 Apps that implement these services must
declare the services they support and use system frameworks to
implement the relevant aspects of those services. Declaring the
services lets the system know which services you use, but in some
cases it is the system frameworks that actually prevent your
application from being suspended.
Your app seems to be ok for the
Apps that play audible content to the user while in the
background,such as a music player app
While your app is playing music you can do the calculation you are mentioning. For more info check the Apple documentation here

Can an iphone app process audio input while the phone is in sleep mode

I need to build an app that can take in a user audio input and process it even if the phone is in sleep mode. For example, if a user says "Hello", then app needs to recognize that and process it even if the phone is in sleep mode. I have read posts that explain how to prevent a phone from going into sleep mode and that would be my second option if the app cannot read the audio input while the phone is in sleep mode.
I'm afraid that's not possible, there are 5 different types of apps that can keep on running on the background, these are (from the Apple documentation):
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
if your app is not doing any of these, your app will not execute code when it goes onto the background. Also, you should declare that your app is performing one of these functions before sending it to Apple for review.

iOS background application network access

I have an application that requires location tracking and I think it fits squarely within one of the allowable background models. However, I need to post to a network service when there are significant changes of location. I've seen write-ups that state network access is prohibited in background processing, but I didn't read that in Apple's docs.
Does anyone know if it's kosher (wrt Apple policies) to make occasional and very quick network updates in a background process?
Good point, according to the Apple documentation only the following usages are allowed in background and each service should be registered:
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 a Newsstand app that downloads and processes magazine 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.
Other than this services, you can create a Finite-Length Task in the Background that actually give you the possibility to end a network process.
This can be important if your app is performing some important task,
such as writing user data to disk or downloading an important file
from a network server.
Regarding your question, it's not really clear if you can or not can do a quick network connection if you've a location service running in background. I would say YES for a short connection, but not totally sure. Since iOS 4.0 this usage was denied and clear in documentation, now that part has been removed.
Yes if you use background for just quick connection. Apple won't allow you to run in the background as you want.
NO If your app does not fall in the Voip, music or GPS category; then you can't run in background.
more here: Update my app when it is in background
You could use ASIHTTPRequest.
ASIHTTPRequest has a property setShouldContinueWhenAppEntersBackground:. default is NO, you may turn on YES so you have background network process.
Apple documentation seems a bit unclear on the strict policy. There are definitely applications in the app store that make sporadic network calls while running in the background as a location-based application. An example is the Geoloqi application.

Which applications launch into background state?

I'm reading through the multitasking documentation, and it has a few references to apps which launch directly into the background state, never entering the foreground state. Is this really allowed for regular apps? Can anyone give me an example of an app like this?
VoIP apps are the biggest one to use this feature. Basically a VoIP app can register itself with the system to be notified when network traffic is intended for it at which point the app takes over handling the incoming traffic (i.e. receiving a call). Skype and Viber both use it.
From the iOS Developer Library (emphasis mine):
Including the voip value in the
UIBackgroundModes key lets the system
know that it should allow the
application to run in the background
as needed to manage its network
sockets. An application with this key
is also relaunched in the background
immediately after system boot to
ensure that the VoIP services are
always available.
The significant location changes backgrounding service also allows an app to be updated with the new location even if it's not running.
Other than those two cases, an app can't do anything from a terminated state until the user launches it.
When you use location manager with significantchange notification, App gets backgrounded automatically if the app is killed, when there is a location event

Running app continuously in background on 3GS and 4

In order to run the app continuously in the background on the 3GS and iPhone4 on OS4.1
is it simply enough to call BeginBackgroundTask in the DidEnterBackground callback and then
NOT call EndBackgroundTask ie to leave it running. I understand this will run the battery
down but that is ok as my users will be running on power.
If this is not the way to do it , can someone say how to keep the app running (not suspended)
Thanks
You cannot keep the app running on the background.
You can declare some tasks that the system will run in background.
According to the Apple documentation:
Support for some types of
background execution must be declared
in advance by the application that
uses them. An application does this by
including the UIBackgroundModes key in
its Info.plist file. This key
identifies which background tasks your
application supports. Its value is an
array that contains one or more
strings with the following values:
audio - The application plays audible
content to the user while in the
background. location - The application
keeps users informed of their
location, even while running in the
background. voip - The application
provides the ability for the user to
make phone calls using an Internet
connection. Each of the preceding
values lets the system know that your
application should be woken up at
appropriate times to respond to
relevant events. For example, an
application that begins playing music
and then moves to the background still
needs execution time to fill the audio
output buffers. Including the audio
key tells the system frameworks that
they should continue playing and make
the necessary callbacks to the
application at appropriate intervals.
If the application did not include
this key, any audio being played by
the application would stop when the
application moved to the background.
In addition to the preceding keys, iOS
provides two other ways to do work in
the background:
Applications can ask the system for
extra time to complete a given task.
Applications can schedule local
notifications to be delivered at a
predetermined time. For more
information about how to initiate
background tasks from your code, see
“Initiating Background Tasks.”