禁用/启用组件
版本码(bundleVersion)
静态配置字符串
显示之间的最大天数
强制类型:屏幕属性
推荐类型:反馈屏幕属性
变更日志类型:商店评论屏幕属性
默认用法
初始化应用守护者
// Simply use the prepare method for default configuration properties
AppGuard.default.prepare()
// Configure the dataSource
AppGuard.default.dataSource = self
// And optionnaly the uiDelegate
AppGuard.default.uiDelegate = self
实现数据源
这很有必要来实现它,以指示演示者控制器到 AppGuard
,并且可选地与 UIImageView
做一些事情。
// MARK: - AppGuardDataSource
extension ViewController: AppGuardDataSource {
func configureImageView(_ imageView: UIImageView?) {
// Do anything with the UIImageView,
// 1- Download an Image with Kingfisher
// 2- Add a Lottie animated subview on it
}
func guardPresenterController() -> UIViewController? {
return self
}
}
实现 UI 代理
UI 代理将发送生命周期和用户交互事件给您。
强烈建议实现 didChooseLater:
和 didChooseAction:
。
// MARK: - AppGuardUIDelegate
extension ViewController: AppGuardUIDelegate {
func guardControllerWillAppear(for context: AppGuardContextType) {
print("guardControllerWillAppear")
}
func guardControllerDidAppear(for context: AppGuardContextType) {
print("guardControllerDidAppear")
}
func guardControllerWillDisappear(for context: AppGuardContextType) {
print("guardControllerWillDisappear")
}
func guardControllerDidDisappear(for context: AppGuardContextType) {
print("guardControllerDidDisappear")
}
func didChooseLater(for context: AppGuardContextType) {
print("didChooseLater")
}
func didChooseAction(for context: AppGuardContextType) {
if context == .mandatoryUpdate || context == .recommandedUpdate {
UIApplication.shared.openURL(URL(string: "https://itunes.apple.com/fr/app/<your app ID>")!)
}
}
}
更新 AppGuard 配置
AppGuard 使用简单的字典数据来更新其配置。
let configurationData // a [String: Any?] instance from JSON file or static dictionnary or anything else
AppGuard.default.updateConfig(from: configurationData)
// Ask the guard 💂♀️ if we can pass
AppGuard.default.displayUpdateStatus()
// You can force it too 💂♀️🤷♂️
AppGuard.default.displayUpdateStatus(forced: true)
自定义键绑定
ℹ️您可以使用 AppGuardConfigurationKeysBinder
选定指定键绑定,将源配置绑定到 AppGuard 配置。默认情况下,将使用 AppGuardConfigurationKeys
的 rawValues。
假设您有一个如下的自定义 JSON 结构
{
"my_deeplink_key": "http://www.google.custom",
"my_dialog_type_key": 1,
"my_content_key": "Custom content text",
"my_action_label_key": "Custom action label",
"my_changelog_content_key": "Custom changelog text",
"my_title_key": "Custom title",
"my_imageurl_key": "Custom image URL",
"my_laterButtonLabel_key": "Later",
"my_maxDaysBetweenDisplay_key": 3,
"my_versionCode_key": 2
}
使用 AppGuardConfigurationKeysBinder
修改默认键绑定
let binding: [String: String?] = [AppGuardConfigurationKeys.deeplink.rawValue: "my_deeplink_key",
AppGuardConfigurationKeys.dialogType.rawValue: "my_dialog_type_key",
AppGuardConfigurationKeys.content.rawValue: "my_content_key",
AppGuardConfigurationKeys.actionButtonLabel.rawValue: "my_action_label_key",
AppGuardConfigurationKeys.changelogContent.rawValue: "my_changelog_content_key",
AppGuardConfigurationKeys.title.rawValue: "my_title_key",
AppGuardConfigurationKeys.imageUrl.rawValue: "my_imageurl_key",
AppGuardConfigurationKeys.versionCode.rawValue: "my_versionCode_key"]
AppGuardConfigurationKeysBinder.bindConfigurationKeys(binding)
自定义
用户内容查看控制器定制
您可以简单地覆盖默认控制器的 .xib
名称。
AppGuardChangelogViewController
AppGuardUpdateViewController
例如,创建一个设置 StarsKit 模块为拥有者的 AppGuardChangelogViewController.xib
文件。IB_OUTLETS 是可选的,因此您可以选择要覆盖什么或不覆盖什么。
记得 IBAction 链接!

注意:即将提供对 UIViewController
自定义类的支持。
UI 定制 - AppGuardGraphicContext
您可以将 AppGuardGraphicContext
设置为您自己的值。
AppGuard.default.graphicContext.actionButtonBackgroundColor = UIColor.ex.fromHexa("#17b8c5")
AppGuard.default.graphicContext.jellyCustomTransition = myCustomJellyPresentation
AppGuard.default.graphicContext.buttonCornerRadius = 5
可自定义的属性为
cornerRadius: CGFloat
roundedButton: Bool
actionButtonBackgroundColor: UIColor?
actionButtonTitleColor: UIColor
actionButtonFont: UIFont
laterButtonBackgroundColor: UIColor?
laterButtonTitleColor: UIColor
laterButtonFont: UIFont
titleFont: UIFont
titleColor: UIColor
contentFont: UIFont
contentColor: UIColor
image: UIImage?
jellyCustomTransition: JellyPresentation
过渡和显示(水母状效果)
AppGuard 使用水母状效果进行可自定义的过渡。您可以通过 AppGuardGraphicContext
中的 jellyCustomTransition
属性指定自己的效果。

更多关于 Jelly 存储库 的信息。
字符串定制(即将推出)
您可以使用配置字符串或本地izable字符串,您可以在您的应用程序包中覆盖这些字符串。
使用 Firebase 远程配置

如果你的应用已经使用Firebase,为什么不使用
Firebase Remote Config功能呢?AppGuard将能够将你关联的Firebase远程配置对象转换为自读数据字典
👌.
安装
添加Firebase Podspec
pod 'AppGuard/FirebaseRemoteConfig'
// Bind the properties keys if needed before
// or use the default ones in the remote config
let remoteConfig = RemoteConfig.remoteConfig()
remoteConfig.fetch(withExpirationDuration: 1.second) { (status, _) in
remoteConfig.activateFetched()
AppGuard.default.updateConfig(from: remoteConfig)
AppGuard.default.checkUpdateStatus()
}
贡献者
制作于🇫🇷由Smart&Soft的iOS团队。
许可证
AppGuard采用MIT许可证。有关更多信息,请参阅LICENSE文件。