2018.01苹果App 检测更新
2018-01-30 本文已影响215人
光彩影
前言:一直APP集成更新功能我们在会被拒,但是最近发现很多APP都弹出了更新提示。并且产品也希望有此功能,所以特意去了解,并App加入更新提示功能。
1. app更新检测功能是否会被拒?
苹果是有明确的规定是:app更新检测是会被拒的。 但是个人总结:苹果的规定是:app内不许出现去更新,或检测更新的确切操作(例如Android:app设置里面检测更新功能)。结论是:可以根据去APP store 里面的更新状态,与本地版本对比,然后弹出更新提示。 为保险:审核期间根据服务端控制,隐藏检测更新功能。
2. 功能实现
1. 获取App Store 本app的信息
请求http://itunes.apple.com/cn/lookup?id=908915361,地址即可。
/cn ,cn是中国的标准,因为itunes有区分国际,所以必须在链接那加上cn。
id是appId, 从itunes -> APP信息 -> Apple ID 获得。
请求结果:
{
"resultCount":1,
"results": [
{"artistViewUrl":"https://itunes.apple.com/cn/developer/mbalib/id908915364?uo=4", "artworkUrl60":"http://is1.mzstatic.com/image/thumb/Purple128/v4/32/d9/ca/32d9ca9c-caa5-b1bc-387d-2782f4e82b54/source/60x60bb.jpg", "artworkUrl100":"http://is1.mzstatic.com/image/thumb/Purple128/v4/32/d9/ca/32d9ca9c-caa5-b1bc-387d-2782f4e82b54/source/100x100bb.jpg",
"ipadScreenshotUrls":["http://is5.mzstatic.com/image/thumb/Purple122/v4/15/68/dc/1568dcf9-5695-b61a-92a9-fd07221ec2f1/source/552x414bb.jpg", "http://is2.mzstatic.com/image/thumb/Purple111/v4/07/e8/f6/07e8f6c0-0afa-b87e-944f-53321ab8ed34/source/552x414bb.jpg", "http://is5.mzstatic.com/image/thumb/Purple111/v4/77/61/dd/7761dd83-bdf5-a309-b1ac-f53f514d01c7/source/552x414bb.jpg", "http://is4.mzstatic.com/image/thumb/Purple127/v4/8b/47/08/8b47084d-d468-92a7-9a55-c87fba3dc48c/source/552x414bb.jpg", "http://is3.mzstatic.com/image/thumb/Purple111/v4/7e/d0/ec/7ed0ec1f-4d8c-caa4-fa8e-7479f18b44d6/source/552x414bb.jpg"], "appletvScreenshotUrls":[], "artworkUrl512":"http://is1.mzstatic.com/image/thumb/Purple128/v4/32/d9/ca/32d9ca9c-caa5-b1bc-387d-2782f4e82b54/source/512x512bb.jpg", "isGameCenterEnabled":false, "kind":"software",
"supportedDevices":["iPad2Wifi-iPad2Wifi", "iPad23G-iPad23G", "iPhone4S-iPhone4S", "iPadThirdGen-iPadThirdGen", "iPadThirdGen4G-iPadThirdGen4G", "iPhone5-iPhone5", "iPodTouchFifthGen-iPodTouchFifthGen", "iPadFourthGen-iPadFourthGen", "iPadFourthGen4G-iPadFourthGen4G", "iPadMini-iPadMini", "iPadMini4G-iPadMini4G", "iPhone5c-iPhone5c", "iPhone5s-iPhone5s", "iPadAir-iPadAir", "iPadAirCellular-iPadAirCellular", "iPadMiniRetina-iPadMiniRetina", "iPadMiniRetinaCellular-iPadMiniRetinaCellular", "iPhone6-iPhone6", "iPhone6Plus-iPhone6Plus", "iPadAir2-iPadAir2", "iPadAir2Cellular-iPadAir2Cellular", "iPadMini3-iPadMini3", "iPadMini3Cellular-iPadMini3Cellular", "iPodTouchSixthGen-iPodTouchSixthGen", "iPhone6s-iPhone6s", "iPhone6sPlus-iPhone6sPlus", "iPadMini4-iPadMini4", "iPadMini4Cellular-iPadMini4Cellular", "iPadPro-iPadPro", "iPadProCellular-iPadProCellular", "iPadPro97-iPadPro97", "iPadPro97Cellular-iPadPro97Cellular", "iPhoneSE-iPhoneSE", "iPhone7-iPhone7", "iPhone7Plus-iPhone7Plus", "iPad611-iPad611", "iPad612-iPad612", "iPad71-iPad71", "iPad72-iPad72", "iPad73-iPad73", "iPad74-iPad74", "iPhone8-iPhone8", "iPhone8Plus-iPhone8Plus", "iPhoneX-iPhoneX"], "features":["iosUniversal"],
"screenshotUrls":["http://is2.mzstatic.com/image/thumb/Purple117/v4/09/86/2e/09862e55-e159-e23c-f482-b716abf092c3/source/392x696bb.jpg", "http://is3.mzstatic.com/image/thumb/Purple111/v4/85/d9/ea/85d9ea17-4629-4f16-f89b-f1a6be9dfa82/source/392x696bb.jpg", "http://is2.mzstatic.com/image/thumb/Purple127/v4/53/e1/20/53e12020-d159-381f-8728-de5435bb062d/source/392x696bb.jpg", "http://is3.mzstatic.com/image/thumb/Purple111/v4/bf/31/83/bf318306-7c11-7147-d815-e8bfe389941f/source/392x696bb.jpg", "http://is5.mzstatic.com/image/thumb/Purple82/v4/b8/e9/60/b8e960b7-a57c-58ed-37ac-61e51a03f98d/source/392x696bb.jpg"], "advisories":[], "trackCensoredName":"MBA智库百科-手机学经济管理必备工具",
"trackViewUrl":"https://itunes.apple.com/cn/app/mba%E6%99%BA%E5%BA%93%E7%99%BE%E7%A7%91-%E6%89%8B%E6%9C%BA%E5%AD%A6%E7%BB%8F%E6%B5%8E%E7%AE%A1%E7%90%86%E5%BF%85%E5%A4%87%E5%B7%A5%E5%85%B7/id908915361?mt=8&uo=4", "contentAdvisoryRating":"4+", "languageCodesISO2A":["ZH"], "fileSizeBytes":"30774272", "averageUserRatingForCurrentVersion":4.5, "userRatingCountForCurrentVersion":18, "trackContentRating":"4+", "sellerName":"mbalib", "genreIds":["6017", "6002"], "currentVersionReleaseDate":"2017-12-14T02:25:44Z", "currency":"CNY", "wrapperType":"software", "version":"4.6.2", "artistId":908915364, "artistName":"mbalib", "genres":["教育", "工具"], "price":0.00,
"description":"MBA智库百科是中国知名的中文经济、金融、管理、法律百科。\n\nMBA智库百科为MBA智库旗下频道,于2006年10月推出。作为专业经济管理理论学习交流的百科频道,其囊括了企业管理者、创业者、学者专家、MBA学生及对企业经营管理等各种感兴趣的人群。\n\n在MBA智库百科客户端,你可以:\n\n*每日精选经管热点、新词推荐,实时跟进财经大小事\n\n*本周推荐和热门推荐,集中掌握优秀条目,进行针对性阅读\n\n*云端同步,离线缓存,专业理论学习探讨随时随地随心进行\n\n……\n\n【MBA智库获得成就】\n\n专业经济管理类中文网站\nGOOGLE财经类专业网站\nWIKI类媒体 \n\nMBA智库已入驻了搜狐新闻、腾讯新闻、ZAKER、今日头条、一点资讯,您也可以随时在其中发现专业人士的推荐文章。\n\n来MBA智库百科,发现更大的世界。\n\n【联系我们】\n\nMBA智库百科链接 :http://wiki.mbalib.com\nMBA智库百科微信 :mbalibwiki\nMBA智库微博 :@MBA智库\n用户反馈邮箱 :wiki@mbalib.com", "bundleId":"com.mbalib.ios.wiki", "trackId":908915361, "trackName":"MBA智库百科-手机学经济管理必备工具", "releaseNotes":"1、可以购买课程的M币来了\n2、产品经理戳著IOS工程师的头,让他改了好多个BUG;\n3、安装包更小了,妈妈再也不用担心我的流量;", "isVppDeviceBasedLicensingEnabled":true, "primaryGenreName":"Education", "releaseDate":"2014-08-21T23:47:09Z", "formattedPrice":"免费", "minimumOsVersion":"8.0", "primaryGenreId":6017, "averageUserRating":4.5, "userRatingCount":283}]
}
trackViewUrl:常规方式下跳转AppStore的链接。
version:最新的版本号。
trackId:应用内模态AppStore需要的应用id。
APPReleaseNotes:应用更新的内容。
2.AppStore的跳转方式
- 跳到appstrore
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:trackViewUrl]];
- 模态弹窗
#import <StoreKit/StoreKit.h>
//初始化和赋值操作、设置代理
SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];
storeViewController.delegate = self;
NSDictionary *parametersDic = @{SKStoreProductParameterITunesItemIdentifier:[userDefault objectForKey:TRACK_ID]};
[storeViewController loadProductWithParameters:parametersDic completionBlock:^(BOOL result, NSError * _Nullable error) {
if (result) {
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:storeViewController animated:YES completion:^{
}];
}
}];
//代理方法
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
[[UIApplication sharedApplication].keyWindow.rootViewController dismissViewControllerAnimated:YES completion:^{
}];
}
3. 集成pods
已有一个框架AYCheckVersion https://github.com/AYJk/AYCheckVersion 已经实现相应功能。原理懂后,直接集成即可。
pod 加入 :
pod 'AYCheckVersion'
用法 :
AYCheckManager *checkManger = [AYCheckManager sharedCheckManager];
[checkManger checkVersion];
使用默认属性进行版本的检测。
- (void)checkVersion;
自定义警示框的标题,下次提示的标题,立即更新的标题。
- (void)checkVersionWithAlertTitle:(NSString *)alertTitle nextTimeTitle:(NSString *)nextTimeTitle confimTitle:(NSString *)confimTitle;
自定义警示框的标题,下次提示的标题,立即更新的标题,跳过该版本的标题。
- (void)checkVersionWithAlertTitle:(NSString *)alertTitle nextTimeTitle:(NSString *)nextTimeTitle confimTitle:(NSString *)confimTitle skipVersionTitle:(NSString *)skipVersionTitle;
如果你想在当前应用中以模态视图的形式打开AppStore,请设置openAPPStoreInsideAPP,默认从应用跳转出去到AppStore。
checkManger.openAPPStoreInsideAPP = YES;