Skip to content

Instantly share code, notes, and snippets.

@alansvits
Created October 19, 2018 18:10
Show Gist options
  • Save alansvits/809287b6e3cc546245a618bf53566d70 to your computer and use it in GitHub Desktop.
Save alansvits/809287b6e3cc546245a618bf53566d70 to your computer and use it in GitHub Desktop.
How to detect first time app launch on an iPhone
func isAppAlreadyLaunchedOnce()->Bool{
let defaults = UserDefaults.standard
if let isAppAlreadyLaunchedOnce = defaults.string(forKey: "isAppAlreadyLaunchedOnce"){
print("App already launched : \(isAppAlreadyLaunchedOnce)")
return true
}else{
defaults.set(true, forKey: "isAppAlreadyLaunchedOnce")
print("App launched first time")
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment