如何检测iOS中首次启动的Apps? [英] How to detect Apps first launch in iOS?
本文介绍了如何检测iOS中首次启动的Apps?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户第一次打开我的应用程序时,我想显示一个欢迎屏幕.有什么方法可以检查Swift中应用程序的首次启动?
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?
推荐答案
Swift 4和更高版本
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
}
}
注意:用户重新安装应用并首次启动后,此方法将返回false
.
Note: This method would return false
after user re-installs app and launch first time.
这篇关于如何检测iOS中首次启动的Apps?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文