跳转到App Store的详情,评论, QQ的某一界面 微信的某一界面

     在开发中,我们有的时候需要跳转到各种各样的应用,其实跳转都有一个共性,每一个跳转只需要知道协议链接就好啦

  跳转到详情,评论


// 跳转到详情
NSString *str = [NSString stringWithFormat: @"itms-apps://itunes.apple.com/cn/app/id%@?mt=8", AppId];
UIApplication *app = [UIApplication sharedApplication];
NSURL *url = [NSURL URLWithString:str];
if ([app canOpenURL:url]) {
    [app openURL:url];
}

// 跳转到评论
NSString *str = [NSString stringWithFormat: @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@", AppId];
UIApplication *app = [UIApplication sharedApplication];
NSURL *url = [NSURL URLWithString:str];
if ([app canOpenURL:url]) {
     [app openURL:url];
}

跳转到微信

  NSURL * url = [NSURL URLWithString:@"weixin://"];
        BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:url];
        //先判断是否能打开该url
        if (canOpen)
        {   //打开微信
            [[UIApplication sharedApplication] openURL:url];
        }else {
            
        }

跳转到QQ

  NSURL * url = [NSURL URLWithString:@"mqq://"];
        BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:url];
        //先判断是否能打开该url
        if (canOpen)
        {   //打开微信
            [[UIApplication sharedApplication] openURL:url];
        }else {
            
        }

也可以使用UIWebView

/**
 *  客服电话
 */
@property (nonatomic, strong) UIWebView *webView;

- (UIWebView *)webView
{
    if(!_webView)
    {
        _webView = [[UIWebView alloc] initWithFrame:CGRectZero];
    }
    return _webView;
}

// 客服电话
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", self.lbl_Telphone.text]]]];

// 跳到QQ
NSURL *url = [NSURL URLWithString:@"mqq://"];
[self.webView loadRequest:[NSURLRequest requestWithURL:url]];

// 跳到微信
NSString *str =@"weixin://";
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];

发布了82 篇原创文章 · 获赞 93 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/sun_cui_hua/article/details/82835041