【问题标题】:Executing an iMessage Extension app by clicking on a button in the main application通过单击主应用程序中的按钮来执行 iMessage 扩展应用程序
【发布时间】:2019-01-18 14:54:27
【问题描述】:

是否可以通过单击按钮从主应用程序(使用 Swift4 开发)启动我的 iMessage 应用程序扩展?我已经在商店里发布了应用程序,但我不知道怎么做。

【问题讨论】:

    标签: swift4 deep-linking imessage-extension


    【解决方案1】:

    您应该能够为您的应用使用相同的 iTunes 链接,并添加 ?app=messages 查询参数

    以星巴克为例,他们的 App Store URL 是

    https://itunes.apple.com/us/app/starbucks/id331177714

    但启动 iMessage 并启动 iMessage 应用程序的 URL 将是

    https://itunes.apple.com/us/app/starbucks/id331177714?app=messages

    【讨论】:

      【解决方案2】:

      据我所知,直到 iOS 12.1

      这是一个长期存在的要求 - 你只能朝着一个方向前进,从扩展程序到应用程序。

      There's a forum discussion 从 2016 年开始,答案是不可能的。另一个2018 forum question 没有回复。

      从扩展程序到应用程序,请参阅技术described in this blog,使用 URL:

      guard let url: URL = URL(string: "AppName://?myParam=myValue") else { return }
      
      self.extensionContext?.open(url, completionHandler: { (success: Bool) in
      
       })
      

      调用上述代码将打开手机应用。

      您可以在手机应用的 App Delegate 中访问 URL 参数:

      func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
      
      return true
      

      }

      【讨论】:

        猜你喜欢
        • 2018-07-30
        • 2017-02-24
        • 1970-01-01
        • 2017-09-15
        • 2017-01-16
        • 2017-03-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多