zoukankan      html  css  js  c++  java
  • ios 根据 schemes 打开 app

    公司出需求,要让 h5链接直接打开用户的 app,如果没有安装 app 直接跳转到 appStore

    这就需要给 app 配置 schemes 即可

    1、在Info.plist中 LSApplicationQueriesSchemes 添加自己的 scheme

    2、往下面滚动,还是 Info.plist里的 URL Types 里面配置自己的 scheme

    1和2的 schemes 写一直就好,Identifier 写自己app 的 Identifier 即可。

    这这里已经可以在h5链接中打开app 了,但是如果你还想要在打开之后跳到指定页面,或者其他操作:

    3(可选)、在下面方法里统一加判断

        // 添加系统回调方法
        func application(_application: UIApplication, open url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {
              return self.handleOpenUrl(url)
        }
        
        func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
              return self.handleOpenUrl(url)
        }
        
        func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
              return self.handleOpenUrl(url)
        }
        
        func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
              return self.handleOpenUrl(url)
        }
    
        /// 其他程序打开自己
        func handleOpenUrl(_ url: URL) -> Bool {
            let urlString = url.absoluteString
            // 根据 urlString 在这里做支付或者其他打开 app 之后的操作return true
        }

    最后提醒,scheme最好都是小写,因为 url.absoluteString 不区分大小写的。

  • 相关阅读:
    26 转义符 re模块 方法 random模块 collection模块的Counter方法
    25 正则表达式
    24 from 模块 import 名字
    24 from 模块 import 名字
    24 from 模块 import 名字
    23 析构方法 items系列 hash方法 eq方法
    21 isinstance issubclass 反射 _str_ _new_ _len_ _call_
    20 属性, 类方法, 静态方法. python2与python3的区别.
    python(1)
    python之字符串格式化
  • 原文地址:https://www.cnblogs.com/shen5214444887/p/10254450.html
Copyright © 2011-2022 走看看