I want to show the terms and conditions only the first time of my app launch.
Currently I am writing my code in didFinishLaunchingWithOptions
.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Handle launching from a notification
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"])
{
NSLog(@"Already Run");
}
else
{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"HasLaunchedOnce"];
[[NSUserDefaults standardUserDefaults] synchronize];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
FirstPage * termsView = [storyboard instantiateViewControllerWithIdentifier:@"FirstPage"];
UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:termsView];
self.window.rootViewController=navController;
// This is the first launch ever
}
}
UPDATE::
What I want when my application launched first time in TERMSandCONDITIONSVC
I have an Accept
Button. When User Accepts
the aggrement then only He allowed go further.
Problem With Above Code:
When i run my app first time TermsandCondition
displayed to me.I press home button the app goes in Background.Again I open The app from launcher and TermsandCondtion
showed.
But When I put my app in Background and By adouble tapping Home button remove it from background and run the app I am directly transfered to my home screen.
No terms and conditions.
How Can i recover from this.