No delegates were triggered if app is in backgroundmode - iphone

I am at the beginning with RestKit-development. I develop an app that
get data from a Server and map these in objects. With a trick of
silence music, is it possible to send request to the backend, if the
app is in background mode . If I
leave the app the request will send, but the delegate of "finish with
objectmapping" will not throw, but if I start (activate the app) the
app, the delegates
will fire. Is there are a way, to map the json if the app is in
background mode?

I've provided an answer to your other post which I think will help you here. See link:
Your other post

Yes, if you configure your application to have a background mode that plays music and play audio while you want your application to continue to run. You can use a silent audio file if you don't actually want to play music so long as you don't want to distribute it through the App Store, but Apple will not approve it for the App Store unless there is actual music as an actual feature in your application.

Related

After unlock iPhone application must be active in background

In my application I want that my application being active even after termination of application. I want that when "slide to unlock" my appliaction is launched.
It is possible? How can I do it without jailbreaking & all...
It is a convenience feature for the user. The application is an audio player and should start playing music immediately when the user unlocks his iPhone or speaking a text "Welcome to iPhone" or something like that.
Please clarify more about it that what you want to do. For this you might be use jail broken tools.
Use this link
http://www.redmondpie.com/how-to-unlock-any-jailbroken-iphone-on-any-baseband-and-firmware/
http://www.redmondpie.com/how-to-unlock-any-jailbroken-iphone-on-any-baseband-and-firmware/

Running the code when application is in the background or device is locked

I have a piece of code wherein I make a server call and based on the response I play a sound. Now, this does not work when my application is in background or my devicei is locked.
Is there any way we can execute this piece of code (Server call and response handling) even if app is in background or device is locked?
There is no general solution, which is by design. (Apple does not want you to have a potentially CPU- and power-intensive process running in the background and degrading user experience.)
There are a few limited-case options available:
You said you want to play a sound. If by this you mean "play music" or some such streaming, there is an audio background task that your application can register to perform. Note that you must actually be streaming audio; Apple rightfully frowns upon apps that try to use this approach to circumvent the general-case prohibition and will reject your App Store submission accordingly.
You can invert your scenario and have the server send a push notification through the Apple Push Notification service. Depending on the user's settings, an alert, badge, or sound can result. This might be the best fit for you if you aren't streaming audio.
If what you are really intending to do is, say, finish an upload or download (and the sound is a completion notification), you can request some additional time to finish that task after the app is nominally backgrounded or the device locked. Use -[UIApplication beginBackgroundTaskWithExpirationHandler:] from within the appropriate UIApplicationDelegate methods to register such a task. Note that you have a limited (but appreciable) amount of time to finish your task, and I don't think you can play media in this mode.

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.

Why does my iPhone App continue in the background?

I wrote my first iPhone App, and managed to get it into the App store. I later discovered a bug that happens on a real device but not on my emulator. I have committed a fix (changed plist to prevent app running in background), but I don't really understand why it happened.
My App allows users to record a sound-byte, however while they are recording they can use the iPhone home button to move the app to the background, and then it can keep recording forever if they don't restart the phone or the app does not crash.
My impression from everything I have read, is that this should not happen as you have to ask for background audio specifically if you want to do this, but now it appears to me that you have to ask specifically to disable it.
Could anyone explain this to me?
The iOS App lifecycle is described in Apple's iOS App Programming Guide.
The App is given the opportunity to save data and otherwise stop things that don't need to be running, before being suspended. You can request extra time doing this by using beginBackgroundTaskWithExpirationHandler:.
If you want your app to stop doing its "normal thing" when it is put into the background then you need to detect the App state transition and stop it yourself.

How do I send my application to background?

I want to run my application in background ...
What things must I do to support this?
Not sure what you really want. You can't put your application into background, only the user can do that. You should read the documentation on the few things that an app is allowed to do when in background. Location tracking, play music and continue VOIP calls.