要运行示例项目,首先克隆仓库,然后从 Example 目录运行 `pod install`。
StanwoodDialog_iOS 可通过 CocoaPods 获取。要安装,只需将以下行添加到您的 Podfile 中。
pod 'StanwoodDialog'
将 `import StanwoodDialog
` 添加到代码中,并从您调用 `AppDelegate` 的 `applicationDid BecomeAvailable` 的地方调用以下方法。
if RatingDialog.shouldShow(onLaunch: 5) {
let text1 = "Hi there,\nmy name is John Appleseed,\nthe developer of this app."
let text2 = "Independent developers like me\nrely heavily on good ratings in the app store"
let text3 = "so that we can continue working on apps.\nIf you like this app, I'd be thrilled\nif you left a positive rating."
let text4 = "the stars would be enough, it will only take a few seconds."
let cancel = "Cancel"
let accept = "Rate the app"
let faceUrlString = "https://lh5.googleusercontent.com/-_w2wo1s6SkI/AAAAAAAAAAI/AAAAAAAAhMU/s78iSxXwVZk/photo.jpg"
let bannerUrlString = "https://d30x8mtr3hjnzo.cloudfront.net/creatives/41868f99932745608fafdd3a03072e99"
let appID = "<YOUR_APPID>"
RatingDialog.builder()
.set(paragraph1: text1)
.set(paragraph2: text2)
.set(paragraph3: text3)
.set(paragraph4: text4)
.set(cancelText: cancel)
.set(okText: accept)
.set(faceUrl: faceUrlString)
.set(bannerUrl: bannerUrlString)
.set(tintColor: UIColor.blue)
.buildAppStoreUrl(with: appID)
.set(rootView: (window?.rootViewController?.view)!)
.build()
}
理想情况下,您会从远程获取这些参数。例如,从 Firebase RemoteConfig 进行一些 A/B 测试,或者从 lokalise.co 这样的服务中提供国际化。
如果您没有配置文件和横幅图像的 URL,则可以将这些图像上传到 Firebase 存储(前往 Firebase 中的存储部分并单击[上传图像])。
- 配置文件图像应为 300x300 像素(这将覆盖 100x100 像素的 3 种变体)。
- 横幅图像应为 300x1125 像素(这将覆盖 100x375 像素的 3 种变体)。
测试
在RatingDialog.shouldShow(onLaunch: -1)
中使用负值将导致每次启动时都会显示评分对话框。
此外,在Debug
模式下,启动次数不需要从上次启动起30分钟后增加其计数。
作者
Eugène Peschard,[email protected]
许可证
StanwoodDialog处于MIT许可证下。有关更多信息,请参阅LICENSE文件。