今天刷著微博侨糟,應(yīng)用內(nèi)跳轉(zhuǎn)appstore這種做法鞭缭,
比單純的直接跳轉(zhuǎn)到appstore,感覺更舒服,
于是動手實現(xiàn)了一下炼绘。應(yīng)用內(nèi)跳轉(zhuǎn)appstore,
蘋果官方提供了API接口执泰,6.0以后開始支持唧躲。
- 實現(xiàn)步驟
首先引入頭文件: #import <StoreKit/StoreKit.h>
實現(xiàn)協(xié)議: SKStoreProductViewControllerDelegate
具體的跳轉(zhuǎn)代碼:
SKStoreProductViewController *appStore = [[SKStoreProductViewController alloc] init];
appStore.delegate = self;
// 借鑒了新浪微博的跳轉(zhuǎn)做法,先去跳轉(zhuǎn)再去加載頁面篡腌,體驗感方面會好很多
[self presentViewController:appStore animated:YES completion:nil];
[appStore loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @"ID這個可以在AppStore上面直接拿到"} completionBlock:^(BOOL result, NSError * _Nullable error) {
if (error) {
NSLog(@"錯誤 %@",error);
} else {
}
}];
代理時間回調(diào)方法:
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
[self dismissViewControllerAnimated:YES completion:nil];
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者