我有提示视图(工具提示)。而且我希望每个下载应用程序在我的应用程序中显示1次。当用户下载应用程序时,此工具提示将显示,然后关闭。当用户删除应用程序并再次下载工具提示时,应该可以再次使用。
let options: AMTooltipViewOptions = .init(textColor: Color.guideSubTitle,
textBoxBackgroundColor: Color.guideScreenBackground,
textBoxCornerRadius: 8,
lineColor: Color.guideScreenBackground,
lineHeight: 15,
dotSize: 0,
focusViewRadius: 15,
focustViewVerticalPadding: 0,
focustViewHorizontalPadding: 0)
AMTooltipView(options: options,
message: Localizable.scan_open_from_gallery + "\n" + Localizable.scan_clear,
focusView: content.openGalleryBtn, target: self)
而且我有钥匙
public var hintView: Bool {
get {
return setting.bool(forKey: Key.hintView)
}
set {
setting.set(false, forKey: Key.hintView)
}
}
如何控制用户何时删除应用并再次下载
最佳答案
将布尔值存储在UserDefaults
中。用户卸载应用程序后,数据将被删除。
在您的 AppDelegate.swift 中
let DEFAULTS = UserDefaults.standard
var isUserFirstTime = !DEFAULTS.bool(forKey: "isUserFirstLogin") // by default it will store false, so when the user opens the app for first time, isUserFirstTime = true.
然后在你的
didFinishLaunchingWithOptions
函数中 if isUserFirstTime {
// your code here to show toolbar
} else {
// dont show toolbar
}
// once you have completed the operation, set the key to true.
DEFAULTS.set(true, forKey: "isUserFirstLogin")