In first time open application it has to show My company splash
screen, in my app I am given login credentials for parents. After
login into app it has to register that user to particular school.
An easy way to go about this would be to set a BOOL in your AppDelegate to test if it's the first launch of your app.
In AppDelegate.m
you could check if it's the first load of the app by doing something like this in
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Check if app has loaded before
[self checkUserDefaults];
// Another method to determine what the first screen the user sees is
[self setInitialViewController];
return YES;
}
...further down you could do something like this
// make a section for UserDefaults
#pragma mark - User Defaults
- (void)checkUserDefaults {
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"hasLaunchedOnce"])
{
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"hasLaunchedOnce"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
Next time user open app it has to show particular school splash screen
what ever that school is added in admin panel. If is possible? How?
You could also create a method in AppDelegate
that determines where to go next, based on NSUserDefaults
:
- (void)setInitialViewController {
UIStoryboard *storyboard = self.window.rootViewController.storyboard;
// Check if there's a key created or if the key exists
if ([[[NSUserDefaults standardUserDefaults]valueForKey:@"hasLaunchedOnce"]boolValue] == NO || ![[NSUserDefaults standardUserDefaults] boolForKey:@"hasLaunchedOnce"]) {
// set to instantiate first launch VC
UIViewController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"initialVC"];
self.window.rootViewController = rootViewController;
} else {
UIViewController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"schoolSelectedVC"];
self.window.rootViewController = rootViewController;
}
[self.window makeKeyAndVisible];
}
Somewhere down the line on your Initial Scene, you'd want to update your NSUserDefaults
to reflect that it's configured for that a school is selected.
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"hasLaunchedOnce"];