Last active
November 5, 2021 02:33
-
-
Save intellitour/9c2cce91cb3ad8296a66e0107d943442 to your computer and use it in GitHub Desktop.
Onboarding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { | |
// Called when a new scene session is being created. | |
// Use this method to select a configuration to create the new scene with. | |
let scene = UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) | |
let hasSeenOnboarding = UserDefaults.standard.bool(forKey: "onboarding") | |
if hasSeenOnboarding { | |
let main = UIStoryboard(name: "Main", bundle: .main) | |
scene.storyboard = main | |
}else { | |
UserDefaults.standard.set(true, forKey: "onboarding") | |
let onboarding = UIStoryboard(name: "Onboarding", bundle: .main) | |
scene.storyboard = onboarding | |
} | |
return scene | |
} | |
override func viewWillAppear(_ animated: Bool) { | |
let hasSeenOnboarding = UserDefaults.standard.bool(forKey: "abc123") | |
if hasSeenOnboarding { | |
UserDefaults.standard.set(true, forKey: "abc123") | |
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()+1) { | |
self.performSegue(withIdentifier: "onboardingDoneSegue", sender: nil) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment