美文网首页
iOS评分功能、APP中打开其他应用程序

iOS评分功能、APP中打开其他应用程序

作者: 咖啡绿茶1991 | 来源:发表于2018-05-07 15:33 被阅读0次

    1、评分功能

    iOS中评分支持功能开发非常简单。

    NSString *str = [NSString stringWithFormat:  

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

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

    只需要这么两行就可以啦,它就会跳转到AppStore的应用位置去咯。

    2、打开其他应用程序

    在程序中打开其他应用程序,需要先设置被打开应用的scheme。

    例如我们在自己做的APP 1中设置scheme,设置方法如下:

    然后在自己的APP 2中添加代码:

    // 1.根据模型拼接url  

    //"scheme://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  

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

    判断本地是否安装要打开的应用:[app canOpenURL:url]

    相关文章

      网友评论

          本文标题:iOS评分功能、APP中打开其他应用程序

          本文链接:https://www.haomeiwen.com/subject/akqvrftx.html