Search code examples
objective-ciphonexcodeios9nsuserdefaults

How to set The Home Page has default Page After User Successfully Register


I am successfully getting the results from the server. is registration is success i want to set the homepage as default.

for this code I am getting the response like:

  Data = {"response":"yes","success":"This mobile registered successfully"}

if response is yes I want to redirect to my home view controller.

When the registration is success when user click on my app automatically my homepage should be open.

Thank you.


Solution

  • When you got Succesfully Response set there

    [[NSUserDefaults standardUserDefaults]setObject:@"Y" forKey:@"login"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    

    then set in application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

    if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"login"] isEqualToString:@"Y"]) 
    {
      CallViewController *loginController=[[UIStoryboard  storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CallViewController"]; 
      UINavigationController *navController=[[UINavigationControlleralloc]initWithRootViewController:loginController];
    
      [navController setNavigationBarHidden:YES];
      self.window.rootViewController=navController;
      self.window.backgroundColor = [UIColor whiteColor];
    
      [self.window makeKeyAndVisible];
    }