Xcode re-opening an app - ios

What method is called if I start my app, press the home button and then start the app again/switch to it by doublepressing the home button and selecting it? It is not any of the following as they do not print anything when I re-enter the app:
- (void)applicationWillEnterForeground:(UIApplication *)application {
NSLog(#"Hi");
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
NSLog(#"Hi");
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSLog(#"Hi");
}
No other methods on this site look like they are called when I change to the app, except for trying to add this piece of code but that didn't help;
- (BOOL)application:(UIApplication *)application shouldRestoreApplicationState:(NSCoder *)coder {
return false;
}
It feels like an extremely easy task but I've been testing all possible methods for 3 hours now. What method is called when I re-enter my application after opening it?
Edit: This has been resolved now, if anyone else is having problems of the same sort this image is super helpful. I found it after resolving my issue: http://www.cocoanetics.com/files/Bildschirmfoto-2012-03-05-um-5.26.29-PM.png

Firstly,
- (void)applicationWillEnterForeground:(UIApplication *)application
method will be called, and after that
- (void)applicationDidBecomeActive:(UIApplication *)application
method will be called after you open the application from the background thread.

Related

iOS: Is this an okay way to detect if the app goes from background to foreground completly?

I need to be able to detect when an App has fully transitioned from background to foreground. I tried using - (void)applicationDidBecomeActive:(UIApplication *)application delegate, but the delegate seems to be called when the application first launches. Then, I tried using - (void)applicationDidBecomeActive:(UIApplication *)application, but it is called before the app has fully transitioned. In the end, I combined the two delegates and it seems to work well for me.
- (void)applicationWillEnterForeground:(UIApplication *)application {
openFromBackground = YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
if (openFromBackground) {
openFromBackground = NO;
// do stuff
}
}
However, I am not sure this is the best way to handle the situation. Any tips or suggestions are appreciated.

applicationDidEnterBackground not called when app screen goes off

AppDelegate.m
- (void)applicationWillResignActive:(UIApplication *)application {
[ScreenState setScreenState:FALSE];
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
[ScreenState setScreenState:FALSE];
}
- (void)applicationWillTerminate:(UIApplication *)application {
[ScreenState setScreenState:FALSE];
}
When I press the Home button or the Standby button, the above code gets triggered, enabling my hackish "ScreenState" static class to monitor whether the screen is active or not.
However, when I don't press anything, the screen shuts down after a few minutes and the above functions do not get called, enabling a very annoying bug to appear to my users...
Anyone has an idea?? This app needs to be in the App Store, so no hacks!

State Preservation and restoration issue

In my application, I need to make a call, So obviously my app go to background while making a call using native call feature.if the call goes long my app is getting killed by IOS itself. Now i need to restore the last view at the time of making a call. I have used Native restoration. What i did is
1. Set the restoration ID for all the views and view controllers.
2. Override the app delegate restoration methods.
My Issue is,
If my app go to background and come back to foreground, Last view is displayed using preservation and suddenly moved to main view(Default launch view). just like last view blinking while coming to fore ground.
Here is my setting:
app Delegate code :
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}
-(BOOL)application:(UIApplication *)application shouldRestoreApplicationState:(NSCoder *)coder
{
return YES;
}
-(BOOL)application:(UIApplication *)application shouldSaveApplicationState:(NSCoder *)coder
{
return YES;
}
-(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}
Main view settings :
Main storyboard contains the login view as a root. Please guide me to fix the restoration issue.
I managed to get rid of the blinking by making the window key and visible in application:willFinishLaunchingWithOptions:.
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window makeKeyAndVisible];
return YES;
}

Global Device Orientation

I want to keep separate Class "Example: Device Manager" with one property "currentDeviceOrientation". from this how to achieve the following state.
When ever app launch first time i want to update the "currentDeviceOrientation" property.
When ever app coming from background to foreground i want to update the
"current DeviceOrientation" property.
According the value of "currentDeviceOrientation" my rootViewController view should get load from - (void)loadView method.
Kindly give good way to solve my problem.
You can use the already built-in methods in AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
}

SHKFacebook handleDidBecomeActive - no knows class method for selector

I'm trying to get Sharekit Facebook sharing to work. Step 7 in the manual states that these methods should be implemented:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[SHKFacebook handleDidBecomeActive];
}
- (void)applicationWillTerminate:(UIApplication *)application
{
[SHKFacebook handleWillTerminate];
}
But XCode gives me an error that handleDidBecomeActive and handleWillTerminate are not class methods of SHKFacebook.
Anyidea what I might have done wrong? I linked ShareKit with Cocoapods.

Resources