iOS应用打开其他程序

 

在程序页面进入iTunes

 NSString *appid = @"717804289";

        NSString *str = [NSString stringWithFormat:

                         @"itms-apps://itunes.apple.com/cn/app/id%@?mt=8", appid];

        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];

 

打电话:

——————————————— 方法一 ———————————————

// 弊端:使用该方法进行拨号之后,当电话挂断之后不会返回应用程序, 会停留在通话记录界面,降低了用户体验,不建议使用

        NSURL *url = [NSURL URLWithString:@"tel://13261936021"];

        [[UIApplication sharedApplication] openURL:url];

        

——————————————— 方法二 ———————————————

        // 在拨打电话之后会提示用户是否拨打, 当电话挂断之后会返回应用程序,能达到理想的用户体验,但是它是苹果公司内部专用,不要使用(上架审核不会通过)

        NSURL *url = [NSURL URLWithString:@"telprompt://13261936021"]; 

[[UIApplication sharedApplication] openURL:url];

——————————————— 方法三  ———————————————
// 建议使用
 [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"tel://13261936021"]]];
 
打开其他程序
协议头:// bundle Identifier  —— 打开应用程序
 
 NSString *path = [NSString stringWithFormat:@"%@://%@", product.scheme, product.identifier];

    NSURL *url = [NSURL URLWithString:path];

     // 2.判断能否打开应用

    UIApplication *app = [UIApplication sharedApplication];

    if ([app canOpenURL:url]) {

        // 2.打开应用程序

        [app openURL:url];

    }else

    {   

// 没有安装应用程序就跳转到AppStore    product.url = "url": "http://itunes.apple.com/app/id415424368?mt=8"

        [[UIApplication sharedApplication] openURL:[NSURL URLWithString: product.url]];

    }

    

 

posted @ 2014-06-22 18:22  翔子的麦田  阅读(437)  评论(0编辑  收藏  举报