1双藕、跳轉(zhuǎn)到App Store 直接編輯評論
NSString *APPID = @"xxxxxxxx";//app ID
NSString *nsStringToOpen = [NSString stringWithFormat: @"itms- apps://itunes.apple.com/app/id%@?action=write-review",APPID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:nsStringToOpen]];
2淑趾、app內(nèi)部直接評分
if (@available(iOS 10.3, *)) {
if([SKStoreReviewController respondsToSelector:@selector(requestReview)]) {
//防止鍵盤遮擋
[[UIApplication sharedApplication].keyWindow endEditing:YES];
[SKStoreReviewController requestReview];
}
}else {
// Fallback on earlier versions
}
3、跳轉(zhuǎn)到某app下載頁面 一般用與打廣告
//第一種方式
NSString *appId = @"xxxxxxxx";
// 創(chuàng)建對象
SKStoreProductViewController *storeVC = [[SKStoreProductViewController alloc] init];
// 設(shè)置代理
storeVC.delegate = self;
// 初始化參數(shù)
NSDictionary *dict = [NSDictionary dictionaryWithObject:appId forKey:SKStoreProductParameterITunesItemIdentifier];
// 跳轉(zhuǎn)App Store頁
[storeVC loadProductWithParameters:dict completionBlock:^(BOOL result, NSError * _Nullable error) {
if (error) {
NSLog(@"錯(cuò)誤信息:%@",error.userInfo);
}else{
// 彈出模態(tài)視圖
[self presentViewController:storeVC animated:YES completion:nil];
}
}];
//第二種方式
Class allow = NSClassFromString(@"SKStoreProductViewController");
if (allow != nil && ![[UIDevice currentDevice].model isEqualToString:@"iPhone Simulator"]) {
NSLog(@"loading");
SKStoreProductViewController *product = [[SKStoreProductViewController alloc] init];
product.delegate = self;
[product loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:@"983122949"} completionBlock:^(BOOL result, NSError * _Nullable error) {
NSLog(@"completion");
NSLog(@"--%d-%@",result,error);
if (!error) {
[self presentViewController:product animated:YES completion:nil];
}else{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@""]];
}
}];
}
#pragma mark -- SKStoreProductViewControllerDelegate
/**
SKStoreProductViewControllerDelegate 方法蔓彩,選擇完成之后的處理
@param viewController SKStoreProductViewController
*/
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController{
NSLog(@"將要退出 App Store 頁面了");
[viewController dismissViewControllerAnimated:YES completion:^{
NSLog(@"已經(jīng)退出 App Store 頁面完成了");
}];
}
4治笨、跳轉(zhuǎn)評論
在iOS 11之前,為了讓用戶直接跳到App Store的評論頁面赤嚼,你的代碼大概是這樣寫的:
-(void)goToAppStore{
NSString *itunesurl = @"[http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=XXXXXXXX&pageNumber=0&sortOrdering=2&type=Purple](https://links.jianshu.com/go?to=http%3A%2F%2Fitunes.apple.com%2FWebObjects%2FMZStore.woa%2Fwa%2FviewContentsUserReviews%3Fid%3DXXXXXXXX%26pageNumber%3D0%26sortOrdering%3D2%26type%3DPurple)+Software&mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:itunesurl]];
}
在iOS 11上不靈了旷赖,直接提示“無法連接App Store”!
我試了一下更卒,果然如此等孵,順便看了一下其他家的APP,不少大廠的APP也掉進(jìn)了這個(gè)坑里還沒爬出來蹂空,比如餓了么俯萌,百度外賣等。經(jīng)過搜索引擎的幫助上枕,我找到了如下辦法:
-(void)goToAppStore{
NSString *itunesurl = @"itms-[apps://itunes.apple.com/cn/app/idXXXXXX?mt=8&action=write-review](https://links.jianshu.com/go?to=apps%3A%2F%2Fitunes.apple.com%2Fcn%2Fapp%2FidXXXXXX%3Fmt%3D8%26action%3Dwrite-review)";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:itunesurl]];
}
注意:把里面的XXX替換成你自己的APP ID咐熙。 如果不知道 APP ID,打包到appstore 的時(shí)候有APP ID
iOS 11 跳轉(zhuǎn)到app設(shè)置
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication]openURL:url];