首页 > 解决方案 > 如何使用gmail模板链接进入移动应用程序

问题描述

嗨,在我的项目中,我们正在使用深度链接。

当用户点击电子邮件模板时,用户需要转到移动应用程序中的关注页面。

通过使用模板我得到这样的链接: TaptoSchedule://host/inner

但后端人员给出的链接如下:https ://www.laundry.com/new-schedule/

我们如何在 iOS 中获得这种类型的功能,请与我分享任何想法。

我遵循这个:http ://swiftdeveloperblog.com/deep-linking-using-custom-url-scheme/

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {

        if defaultValues.value(forKey: accessToken) != nil{

            let urlPath : String = url.path as String
            let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)

            //TaptoSchedule://host/inner

            if(urlPath == "/inner"){

                let innerPage: PickupController = mainStoryboard.instantiateViewController(withIdentifier: "PickupController") as! PickupController
                innerPage.selectedfrom = "Deeplink"
                self.window?.rootViewController = innerPage

            } else if (urlPath == "/about"){

            }
            self.window?.makeKeyAndVisible()
            return true
        }else{
            setRootControllerBeforeLogin()
            return true
        }
    }

标签: iosswiftgmaildeep-linking

解决方案


您可能想使用 Universal Links 而不是 Deep Links。通用链接使用标准的 URL 格式,这似乎是您的后端团队为您提供的。

从客户的角度来看,深度链接和通用链接之间的体验基本相同。但是,通用链接为您提供了一些额外的灵活性。例如,通用链接使用标准 URL 格式,如果您的用户没有安装您的应用程序,它可以链接到网页。

在此处查看 Apple 文档以了解详细信息: https ://developer.apple.com/ios/universal-links/

https://developer.apple.com/documentation/uikit/inter-process_communication/allowing_apps_and_websites_to_link_to_your_content/enabling_universal_links


推荐阅读