iOS App内部打开第三方App 比如:淘宝,京东,拼读多,抖音,快手,微信

news/2024/7/20 21:11:56 标签: ios, swift, 开发语言

工具类中写好类方法

swift"> //MARK: 打开第三方APP
   static func openThirdPartyApp(_ url:String,_ appName:String){
        if let url = URL(string: url) {
            UIApplication.shared.open(url, options: [:]) { boolValue in
                if !boolValue {
                    kWindow.makeToast("请检查是否安装\(appName)App", position: .center)
                }
            }
        }
        else {
            kWindow.makeToast("请检查是否安装\(appName)App", position: .center)
        }
  }

使用

swift"> Utils.openThirdPartyApp("taobao://", "淘宝")
 Utils.openThirdPartyApp("pinduoduo://", "拼多多")
 Utils.openThirdPartyApp("openapp.jdmobile://", "京东")
 Utils.openThirdPartyApp("snssdk1128://", "抖音")
 Utils.openThirdPartyApp("weixin://", "微信")

打开快手有点特殊,需要单独写

swift">    //MARK: 打开快手APP
    static func openKuaiShouApp(){
        if let url1 = URL(string: "kwai://") {
            UIApplication.shared.open(url1, options: [:]) { boolValue in
                print("boolValue=",boolValue)
                if !boolValue {
                    kWindow.makeToast("请检查是否安装快手App", position: .center)
                }
            }
        }
        else if let url2 = URL(string: "ksnebula://") {
            UIApplication.shared.open(url2, options: [:]) { boolValue in
                print("boolValue=",boolValue)
                if !boolValue {
                    kWindow.makeToast("请检查是否安装快手App", position: .center)
                }
            }
        }
        else {
            kWindow.makeToast("请检查是否安装快手App", position: .center)
        }
    }
swift"> Utils.openKuaiShouApp()

http://www.niftyadmin.cn/n/435651.html

相关文章

微信小程序实现选择地区demo,记录最近访问的地区

最终效果图&#xff1a; index.wxml <view class"container"><view class"search_contaniner"><view class"search_box"><input type"text" placeholder"省/市级/区县级" value"{{search_con…

索引常见问题

被问到SQL和索引优化问题&#xff0c;如何切入&#xff1f; 可以用 explain 进行分析 思考流程&#xff1a;找到哪些运行时间长浪费性能的sql&#xff0c;然后再用explain分析 慢查询日志 MySQL可以设置慢查询日志&#xff0c;当SQL执行的时间超过我们设定的时间&#xff0…

SOLIDWORKS Electrical如何绘制电线

SOLIDWORKS Electrical 是一套计算机辅助工程 (CAE) 设计工具&#xff0c;他可以帮助电气设计工程师减少创新的内在风险&#xff0c;并允许公司减少对物理原型的需求&#xff0c;从而在更短时间内以更低成本将产品推向市场。通过一组强大、直观的电气设计功能&#xff0c;设计人…

图的企业应用-A*算法自动寻路

引言 MC想必大家都玩过,但鸡哥利用A*自动寻路算法来找箱子 箱子里有鸡你太美唱片&#xff0c;和准备好的篮球 当然在这是游戏中找到的宝箱 还得原石x5等一大堆的养成物品 ???等等 ,原神 玩家露出鸡脚了吧! 不应该是 有鸡你太美唱片,还有一条鱼并且给梅里猫的名叫荔枝的? 这…

Java8 四大核心函数式接口 Function、Consumer、Supplier、Predicate使用示例

Function<T, R> T&#xff1a;入参类型&#xff0c;R&#xff1a;出参类型 调用方法&#xff1a;R apply(T t); 定义函数示例&#xff1a;Function<Integer, Integer> func p -> p * 10; // 输出入参的10倍 调用函数示例&#xff1a;func.apply(10); // 结…

Node.js:Buffer基础

文章目录 创建Buffer对象Buffer对象的常用方法1. Buffer.from(string[, encoding])2. Buffer.from(array)3. Buffer.alloc(size[, fill[, encoding]])4. buf.toString([encoding[, start[, end]]])5. buf.toJSON()6. buf.compare(otherBuffer)7. buf.copy(target[, targetStart…

Webpack 使用详解

Webpack 是一个现代 JavaScript 应用程序的静态模块打包器。本文将详细介绍如何使用 Webpack&#xff0c;以及提供代码示例。为了保持篇幅&#xff0c;我们将简要介绍 Webpack 的核心概念和功能。 一、核心概念 入口&#xff08;entry&#xff09;&#xff1a;应用程序的起点…

php swoole 请求tcp服务的两种方式

第一种方式 &#xff08;可以实现在代码中调用&#xff09; $task_connection stream_socket_client(tcp://127.0.0.1:8721,$errno,$errstr);$task_data array(route > demo/test,);fwrite($task_connection, json_encode($task_data));if(!empty($errno) || !empty($e…