iOS - 跳转App Store和应用内下载更新app两种方式

1. 跳转App Store 下载

   id99637153*是app的唯一id,负责上架的应该都懂;现在哪还有低于10.0版本的手机啊,该省的则省,废话不多说,直接上代码

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/cn/app/%E4%B8%9C%E6%96%B9%E7%BE%8E%E9%A3%9F/id99637153*?mt=8"] options:@{} completionHandler:nil];

2.应用内更新下载

导入头文件: #import
准守协议:

1.实现代理SKStoreProductViewControllerDelegate

SKStoreProductViewController *storeProductViewContorller = [[SKStoreProductViewController alloc] init];
storeProductViewContorller.delegate = self;
[storeProductViewContorller loadProductWithParameters: @{SKStoreProductParameterITunesItemIdentifier : @"996371534"} completionBlock:^(BOOL result, NSError *error) {
    if(error){
         NSLog(@"错误%@",error);
    }else{
        //应用界面
        [self.window.rootViewController presentViewController:storeProductViewContorller animated:YES completion:nil];
    }
}];

//实现取消协议
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController{
[self.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
[self disMiss];
}

你可能感兴趣的:(iOS - 跳转App Store和应用内下载更新app两种方式)