App going background and auto lock - iphone

Is there any difference between- An iphone app going background and phone is getting auto locked
I am developing an iPhone app
My app resumes its uploading process when it return from background
But it is not working if unlocked from auto locked
What is the issue..I have tried alot,but could not figure it out..Please help me

iOS shuts down WiFi when the screen is off - which is good as far as battery savings.
So please check the wifi connection while uploading..
You can restrict the auto-lock or device resume through programmatically while uploading and enable auto-lock programmatically after done the upload process .
If the device is connected to a power source, then Wifi remains enabled, even if the device goes to sleep. If the device is not connected to a power source, then Wifi is disabled once the device goes to sleep.
This of course was by design in an effort to reduce battery consumption

Related

iOS 7 Bluetooth - app that handles events in background even after phone restart

I want to write a tracking application, which reacts/record when users get in a car and phone automatically pair with Bluetooth hands free. I need also Id of the hands free device.
On Android it is easy, using Broadcast Receiver your app listen to broadcasts that device had been paired with phone. It is working even after phone had been restarted and App did not run after restart.
Is it possible on iOS(7+) ?
You can do it by reading the "Performing Long-Term Actions in the Background" part of this docs
Essentially, using state restoration, the system takes note of what your app was doing when it was killed.
If the app is searching for a bluetooth device and is killed by the system, the system will take care of continuing this research and wake up the app again when the bt device has ben found.
Note that this will work only if the app is killed by the system, not by the user (using the multitask bar). This behavior has changed since iOS 7.
Alternatively, If your BT hardware can be programmed to send advertisements using the ibeacon protocol, your app can be "awakened" by the corelocation/ibeacon api. After that prompt then maybe the corebluetooth pairing code could be initiated.

Airplaying video from url to ATV using lots of battery on iphone

I am writing an app that plays a url using MPMoviePlayerController. The app works in the background and using airplay also works with an ATV, macmini using airserver and XBMC. The url is to a movie file on the local network. The way I understand is that the phone doesn't do any heavy lifting but merely passes the url to the apple tv and as long as the url points to media that the AppleTV supports then it will play.
The problem I am having is that the apple TV must be aggressively pinging the iphone and keeping the wifi active since the battery life is hit really hard. Playing an average sized movie knocks the battery life by about 2/3 on an IPhone 3GS and 1/2 on an IPhone 4S.
If I am playing on the mac mini using air server then the battery life on the phone reduces at the same rate as if the phone was backgrounded and not playing anything. I noticed that if I stop the wifi on the iphone then the movie will keep playing on the mac mini but stops within about 30s on the ATV. I am guessing the ATV keeps pushing out an event saying that it is playing and if it doesn't receive an OK in return then it stops playing.
Is there something I am doing wrong? Have other people experienced the same battery drain using airplay from their phone? I have tried someone else's app and it also did the same.
A packet trace of the traffic would give you a definitive answer. But, assuming the documentation you linked to is correct, your answer may be here:
The AirPlay server is a HTTP server (RFC 2616). Two connections are made to this server, the second one being used as a reverse HTTP connection. This allows a client to receive asynchronous events, such as playback status changes, from a server.
The reverse connection would keep the WiFi radio active.

iphone app network connection disconnect after screen locking with new ios sdk 5.0

My app working with sdk 4.3 just fine, but when i change to sdk 5.0, every time the screen is locking, after just a few seconds, the tcp connection will disconnect.
I use xmppframework, and it gives me an error like
"Error Domain=NSPOSIXErrorDomain Code=57 The operation couldn’t be completed. Socket is not connected"
It seems that the socket was been closed after screen locking.
Is there something changed in sdk 5.0 case this problem?
Regards.
In iOS 4.x when the user initiated the lock screen the app continued to run in the background. Now in iOS 5.0 when the lock screen is initiated the app is sent to the background and you can only do what an app can do in the background. So if you have not made other arrangements than your app will loose network connections.
Do you have UIRequiresPersistentWiFi specified in your info.plist file? The time it takes iOS to shut down WiFi without this setting may have changed between iOS 4.x and 5.0.
When you lock your iphone or ipad, all the network activities are stopped. Wifi connections are dropped. With what Robin has stated, this would work if the ipad is in idle state and not locked. Since there would be no traffic incoming or outgoing, iPad might decide to drop connection to WiFi.

GameKit keeping connection going while device screen off or in background

I am working on an appliction that requires bluetooth connectivity, which i use GameKit for data transfer, however im seeing that when i go in background mode, or I just turn off the screen in app, the bluetooth connection is dropped... Ive seen other apps that keep the connection alive in such situations, anyone have any idea if I am missing something that wont cause the connection to drop on such cases? Have been looking around but havent found anything useful...
Thanks
Daniel
This is not intentionally supported by Apple.
If you are writing this for an application that doesn't have to be distributed through the App Store, you can set the application up to play a silent audio file in the background. This will allow GameKit to continue to work even when your application has been put into the background or if the screen has locked.
If this application has to be distributed through the App Store, Apple require the audio to be a real feature, with audible music playing.
If you have two devices connected using GKSession and then one of them is interrupted by call or goes into background, when it wakes up connection should be still alive (you should be able to send/receive packets between devices).
You may try setting
UIRequiresPersistentWiFi
in your plist.

iphone 3G data network timeout?

My iPhone app sends data persistently over the network, and can handle having the network completely unavailable for a time. However I do my dev on an ipod and have difficulty testing 3G connectivity issues; My question: is there period of non-connectivity, while an app is in the foreground, after which the iphone will stop checking for the network, such that there are no bars and reachability returns 0 until the user "wakes" the phone, e.g. by locking/unlocking? Or can e.g. 1 hr without data network pass and the iphone will recognize that the network is back and reachability will start returning true (I am polling every 1 minute while there is not connection to my server).
This is my experience with wifi: if, while running my app, the ipod hasn't connected to a wifi network for 1/2 hr, it stops looking for networks, and I need to lock and unlock it to stir the device into looking again.
One other thing: the iPhone has the screen dimmed by the proximity sensor while all this persistent network use is happening.
Wi-Fi going down after 30 min of inactivity is a documented behavior. Cellular network is always active, unless turned off by the user. So if it goes down for a while it should get back online automatically when possible even if there was no user activity.