展开URL types,再展开Item0,将Item0下的URL identifier修改为URL Scheme
itunes.apple.com/cn/app/bai-du-wen-kuhd/id483064532?mt=8
然后将 https:// 替换为 itms:// 或者 itms-apps://:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://
itunes.apple.com/cn/app/bai-du-wen-kuhd/id483064532?mt=8"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itunes.apple.com/cn/app/bai-du-wen-kuhd/id483064532?mt=8"]]
// 本App跳转到SecondApp
- (IBAction)appJumpToAnotherAppAction:(id)sender
{
NSURL *url = [NSURLURLWithString:@"shanshan.SecondApp://AAAA"];//通过openUrl进行跳转,可以传递一些参数
if ([[UIApplication sharedApplication]canOpenURL:url]) {
[[UIApplication sharedApplication]openURL:url];
}else{
NSLog(@"应用程序未安装");
}
}
// 本App跳转到AppStore
- (IBAction)AppChangeToAppStore:(id)sender
{
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:@"itms://itunes.apple.com/cn/app/bai-du-wen-kuhd/id483064532?mt=8"]];
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:@"itunes.apple.com/cn/app/bai-du-wen-kuhd/id483064532?mt=8"]];
}
AppDelegate 中的主要代码
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([[urlscheme]isEqualToString:@"shanshan.SecondApp"]) {
NSLog(@"从%@跳转过来的 - %@",sourceApplication,[url resourceSpecifier]);
self.otherString = [[[urlresourceSpecifier]componentsSeparatedByString:@"//"]objectAtIndex:1];
NSLog(@"传递过来的参数 = %@",self.otherString);
}
return YES;
}