在创建动态链接时,我通过向DynamicLinkComponents
添加PercentEncoding来传递URL,如下所示:http://soiree.linekwdemo1.com/soireews/dj_details.php?itemid=1
。
它给了我共享给电子邮件的解码后的长URL:https://soiree.page.link/?link=http://soiree.linekwdemo1.com/soireews/dj_details.php?itemid=1&ibi=com.safacs.soireeapp&ifl=https://soiree.linekwdemo1.com/login.php
和短URL:https://soiree.page.link/52kz7nzdKamfnDhs7
。如果我点击一个链接,它将打开非常好的应用程序。但是下面的方法给了我dynamicLink nil和错误nil。
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
if let incomingURL = userActivity.webpageURL{
let linkHandled = DynamicLinks().handleUniversalLink(incomingURL) { (dynamicLink, error) in
if (error != nil) { }
}
}
}