跳转到设置页面 与appstory
//MARK:系统跳到应用设置页面
func systemMySet(){
let url = NSURL(string: UIApplicationOpenSettingsURLString)
if let url = url where UIApplication.sharedApplication().canOpenURL(url) {
UIApplication.sharedApplication().openURL(url)
}
}
//跳转到系统设置的其他界面需要 在项目中的info中添加 URL types 添加 URL Schemes 为 prefs的url
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];
//MARK:跳转到appstory
func appStory(){
//let url = "http://itunes.apple.com/lookup?id=1125895585"//只在国内的需要加cn
let url = "http://itunes.apple.com/cn/lookup?id=1125895585"
Prequest.requestJSON(.POST, URLString: url, completion: { (response) in
// pprintLog("response:\(response)")
let result = (response?.objectForKey("results"))! as! NSArray
pprintLog("result:\(result)")
let dic = (result.lastObject)! as! NSDictionary
let lineversion = dic.objectForKey("version") as! String
let infoDictionary = NSBundle.mainBundle().infoDictionary
let localVersion : String? = infoDictionary! ["CFBundleVersion"] as? String
if localVersion != lineversion{
let alert = UIAlertController(title: "版本更新", message: "检测到有新版本,前往appstory更新", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "取消", style: UIAlertActionStyle.Cancel) { (UIAlertAction) -> Void in
})
alert.addAction(UIAlertAction(title: "确定", style: UIAlertActionStyle.Default) { (UIAlertAction) -> Void in
//然后将 http:// 替换为 itms:// 或者 itms-apps://:
UIApplication.sharedApplication().openURL(NSURL(string: "http://iTunes.Apple.com/us/app/appid")!)
})
self.presentViewController(alert, animated: true, completion: nil)
}
}) { (failed) in
pprintLog("failed:\(failed)")
}
}
//跳转到app评论页
func appStoryComment(){
let alert = UIAlertController(title: "评价应用", message: "立刻前往appstory评价", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "稍后", style: UIAlertActionStyle.Cancel) { (UIAlertAction) -> Void in
})
alert.addAction(UIAlertAction(title: "确定", style: UIAlertActionStyle.Default) { (UIAlertAction) -> Void in
let url = NSURL.init(string: "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=appid&pageNumber=0&sortOrdering=2&type=Purple+Software&mt=8")
UIApplication.sharedApplication().openURL(url!)
})
self.presentViewController(alert, animated: true, completion: nil)
}
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步