ios - 当我们点击 gmail 中的链接时如何启动我们的应用程序

标签 ios gmail

我在注册到用户注册的帐户后发送了一个链接。 现在我希望当用户从相应帐户点击该链接时,他/她将转到应用程序。

有什么方法可以从在 gmail 应用程序上单击的链接启动我们的应用程序吗?

请帮忙... 谢谢

最佳答案

您需要执行通用链接。对于通用链接,您需要首先创建一个“apple-app-site-association”文件,如下所示:->

{
"applinks": {
    "apps": [],
    "details": {
       "appID": "9JA89QQLNQ.com.apple.wwdc": {
            "paths": [
                "/wwdc/news/",
                "/videos/wwdc/2015/*"
            ]
        }
    }
 }
}

applinks 标签确定哪些应用程序与网站相关联。将 apps 值保留为空数组。在 details 标签内是一组字典,用于链接 appID 和 URL 路径。 appID 由您的团队 ID 和应用程序的 bundle ID 组成。 创建文件后,您需要将其上传到您的域,例如 www.yourHost/apple-app-site-association。 现在您需要转到功能 -> 关联域,在此处添加一个您希望通用的链接,即您希望点击哪个链接来打开您的应用程序。 然后您需要在您的应用程序委托(delegate)类中添加此方法。

  func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
//code here to related universal links
/* The activity type used when continuing from a web browsing session to either a web browser or a native app. Only activities of this type can be continued from a web browser to a native app.
 */
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
  let url = userActivity.webpageURL,
  let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
    return false
}
  //do something 
   return true
}

关于ios - 当我们点击 gmail 中的链接时如何启动我们的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42849441/

相关文章:

ios - 点击另一个单元格时隐藏 datePicker?

email - Delphi 和 Indy 10 无法读取 gmail 电子邮件第二。读完一次后的时间

google-api - 如何访问 Gmail 的 native API?

multithreading - 使用 App-Script 从 Gmail 中的标签名称使用 getThreads() 时,如何防止按主题或日期分组?

ios - 使用 GCD 按顺序发送邮件

ios - 如何使用 iOS 10 语音识别?

ios - Apple Mach O-Linker 错误 Xcode

java - 从外部 Java 程序在网络浏览器上安全登录 Gmail

gmail - 将 Evernote 笔记导出到 Kindle(通过 Gmail?)

ios - 如何检查用户输入的答案是否有字母,如果有,您如何将该答案默认为 0?