【发布时间】:2023-03-19 16:00:01
【问题描述】:
我正在 xcode 6.1 - Swift 中实现评分功能。
我正在关注this 教程,我的问题是如何在应用程序发布之前在应用程序商店中找到它的 URL,即是否存在我们预先添加应用程序名称的默认 URL?
-
使用 AlertController 显示评分选项
var alert = UIAlertController(title: "Rate Me", message: "Thanks for using Lab Cases- Ver 1 Newbrn and Obstetric Haematology", preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "Rate Lab Cases", style: UIAlertActionStyle.Default, handler: { alertAction in UIApplication.sharedApplication().openURL(NSURL(string : "itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=<iTUNES CONNECT APP ID>")!) alert.dismissViewControllerAnimated(true, completion: nil) })) alert.addAction(UIAlertAction(title: "No Thanks", style: UIAlertActionStyle.Default, handler: { alertAction in NSUserDefaults.standardUserDefaults().setBool(true, forKey: "neverRate") alert.dismissViewControllerAnimated(true, completion: nil) })) alert.addAction(UIAlertAction(title: "Maybe Later", style: UIAlertActionStyle.Default, handler: { alertAction in alert.dismissViewControllerAnimated(true, completion: nil) })) self.presentViewController(alert, animated: true, completion: nil)
对 URL 的调用在这里 -
UIApplication.sharedApplication().openURL(NSURL(string : "itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=<iTUNES CONNECT APP ID>")!)
alert.dismissViewControllerAnimated(true, completion: nil)
提前致谢 C
【问题讨论】:
-
Appirater 是您自己实现此功能的绝佳选择,它有许多本地化版本。
-
谢谢,那是 obj c 吗?
-
是的,它在 Objective-C 中。您可以使用Bridging Header 导入它。或者,如果您想扩展您的
func,这将是一个很好的参考。