zoukankan      html  css  js  c++  java
  • 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]];

        }

        

  • 相关阅读:
    Sqlserver 迁移数据库批量迁移作业(Job)
    在VS2010开发的MVC3 应用程序中设定默认的浏览器
    创建继承自System.Web.UI.WebControls.WebControl基类的控件类
    遍历页面控件
    @fontface
    加密配置节点
    视图状态的程序分块
    BlogEngine.NET 1.5的BlogProvider、DbBlogProvider
    避免target特性
    SCOPE_IDENTITY、IDENT_CURRENT 、@@IDENTITY
  • 原文地址:https://www.cnblogs.com/Fc-ios/p/3802811.html
Copyright © 2011-2022 走看看