iPhone app update while still in background - iphone

I was wondering what happens if a user updates an app (through the app store/update) while the app is still in the background on iOS 4.x
I am planning a big update for my next release and I wanted to know if it is a special case I have to handle to avoid a crash.
Or can I trust the OS to restart the application on the next launch (or to kill the background process during the update), detecting that the application has changed instead of just doing a "applicationWillEnterForeground"?

iOS / Apple take care of that use-case for you, you don't need to worry about it. Your app will get terminated, so when the user next taps its icon you will have a relaunch.

Any app in suspended in the iOS "background" can get terminated by the OS at any time. The OS knows to do the "right thing" when the app's icon is tapped on again next. An app update would just be another case of that same thing happening.

Related

Keep iphone unlocked when building it in xcode

When I use the build button in xcode to run my cordova app on the phone, if the build process take too long I get a "Device locked" error.
Is there a way or any hack I can do to keep my iphone unlocked when it's building? Is there a way to tell xcode to keep my phone unlocked?
The easiest fix for this is to disable sleep mode (for up until ~1hr) for your phone. Then you won't have to worry about it locking.
Open the Settings app.
Tap Display & Brightness.
Tap Auto-Lock.
If this option is grayed out, visit this Lock screen settings tip to
learn what to do. Set the lock feature to a time that works for you.
To fiddle with the phone's auto lock duration whenever you're working, and then changing it back to normal is not ideal for me since I use my primary phone for testing apps too. My workaround was to run a youtube video on silent and let iOS switch it to my testing app whenever the build is ready!

iphone lock button and the running app

this may be a simple one, but I don't know the answer.....
For testing whether my location-based app receives updates in background, I usually run the app and then press the Home button to put the app in background. However, I am curious whether pressing the Lock button (at the top) will put the app in background or not.
Regards.
Yes. Hitting the lock button does background the application. However when you unlock it, the application is then brought back to the foreground. Should be able to test this within your App Delegate and simple log statements.

iphone:Multitasking in iphone not possible

Does iphone support multitasking for third party applications.Canone explain me how.
Assuming your device is newer than an iPhone 3G (or 1st gen iPod Touch), then yes, your application may run in the background. Note that even iOS4 doesn't allow multitasking on the older devices. What happens in iOS4 and above is that when you press the home button from an application, it switches the current app to the background - however, it is still running.
When working with games this means you have to use your application delegate to pause your game when the application is sent to the background, and (optionally) resume it when it returns, or present a "pause menu". It should also switch to a low/idle rendering loop (4FPS or similar), however, extra care has to be taken with iPad apps, which do not allow OpenGL rendering in an application that is currently in the background (in my experience). For these cases you have to completely disable the OpenGL render loop. These steps will prevent your application using unnecessary processing power while in the background.
You can see what's currently running in the background by double-tapping the home button on your device. The icons for all the apps will appear in a sliding list at the bottom of the screen. You can press and hold them to bring up the little X's allowing you to terminate the processes.

iPhone - fast-app switching and iOS 4

I'm trying to get the following functionality in my iPhone app:
When backgrounded, stays running (doesn't have to do any background work)
When resumed, app picks up where it was left off
I'm mainly wanting the same screen on my app still up, as there are several UINavigationControllers within a UITabBarController.
I have done all of the following:
Made sure I'm compiling with 4.1 SDK
Set UIApplicationExitsOnSuspend to false
Handle DidEnterBackground and WillEnterForeground in my AppDelegate
Call BeginBackgroundTask in DidEnterBackground, to attempt to keep my app open
I'm using MonoTouch, but that it probably beside the point. I can take answers in Obj-C, for sure.
I've tested my app on a jailbroken phone with Backgrounder, and I see the "app in background" badge disappear immediately after pushing the home button. I also tried setting UIBackgroundModes in my Info.plist, but to no avail.
Is there anything I'm missing?
Or is this something I would have to implement on my own to resume the previous state of my app? Everywhere I've read talks like it should just work automatically.
If you don't want to be doing work in background, don't call beginBackgroundTask. That call is for situations where you want to do some kind of work in the background. And if you don't finish that work fast enough, iOS will terminate your app.
When I upgraded to iOS 4.x, my MT application started exhibiting this behavior without me having to do anything. iOS should take care of it for you.
I finally got in touch with someone on MonoTouch's irc.
In MonoDevelop there is an option to make a dual iPad/iPhone project, which I used. This is causing my app to behave as if it's running with the 3.2 SDK when deployed to the device.
I think my solution is to install the iOS 4.2 SDK that just came out, since this ads the new multi-tasking feature on iPad.
Not only do you need to support going into the background, you also need to support cases where your app has been terminated. In your app’s initialization code, you should resume the state that it was in. For instance, when you push a view controller, use NSUserDefaults to store a value for the currently-displayed screen, and then when you start read that value and display the associated screen.

How to let the app load with Default.png only when it is launched from scratch?

Example: My Default.png image shows the start screen of my app with an empty interface. When the app is launched from scratch the first time, this is cool. It appears like it started quickly. But when the user quits it and the app just goes to background, and then the user opens it, this sucks. Then I always end up with a wrong "snapshot" as launch image and my app then looks completely different after launch because it is like it was left the last time.
I would have to disable the Default.png when my app just goes to background, or I would have to enable it when it gets really terminated. Any way to do this?
It sounds to me like your app isn't being suspended. Every app that I've used that supports fast-app switching hasn't shown its default png when I open it after suspending it.
Are you sure your app is supporting fast-app switching and that it is being suspended?
Just updating my answer for some clarity that was revealed in the comments:
In order to take advantage of fast-app switching, the following conditions need to be met:
App needs to be compiled against the 4.0 SDK
App needs to be running on a multitasking-capable device such as:
iPhone 4
iPhone 3GS
iPod touch 3rd Generation
info.plist must not contain the UIApplicationExitsOnSuspend key.