I would like to display a welcome screen when a user opens my app for the first time. What method is there to check the first launch of an app in Swift?
Overview. Launching an app involves a complex sequence of steps, most of which the system handles automatically. During the launch sequence, UIKit calls methods in your app delegate so you can prepare your app for user interaction and perform any tasks specific to your app's requirements.
The time to initial display (TTID) metric measures the time it takes for an application to produce its first frame, including process initialization (if a cold start), activity creation (if cold/warm), and displaying first frame.
You can use this anywhere to verify that the user is seeing this view for the first time.
func isAppAlreadyLaunchedOnce() -> Bool {
let defaults = UserDefaults.standard
if let _ = defaults.string(forKey: "isAppAlreadyLaunchedOnce") {
print("App already launched")
return true
} else {
defaults.set(true, forKey: "isAppAlreadyLaunchedOnce")
print("App launched first time")
return false
}
}
Note: This method would return false
after user re-installs app and launch first time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With