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]];

        }

        

  • 相关阅读:
    B树,B+树
    中断
    死锁
    无锁队列
    Cookie和Session
    分布式系统一致性
    c++ 标准库迭代器失效
    html5 app图片预加载
    html5 手机APP计算高度问题
    html5 750 REM JS换算方法
  • 原文地址:https://www.cnblogs.com/Fc-ios/p/3802811.html
Copyright © 2011-2022 走看看