ios - 如何在 iOS 中实现深度链接
问题描述
我在我的应用程序中实现深层链接时遇到问题。我正在使用一个名为 accenggage 的通知,可以在这里看到。一旦我按照文档中的指示,在我的代码中使用 AccengageConfig.plist 文件中设置的 conf 启动 SDK,即我做Accengage.start()
在 AppDelegate 的 didFinishLaunchingWithOptions 方法中,我注意到打开 url 的函数从未被调用。但它会在我的日志中打印有效负载,但我无法访问它,以便在我的代码中使用它。如果我评论它,一切都会完美。请有人以前用过这个来看看我哪里出错了。当我在 safari 中打开链接时,它会午餐应用程序,但不会按我的要求打印 url,也不会打开相关视图。我教我的问题是深度链接实现,但事实并非如此,而是我没有正确使用它的 Accengage与 Acengage 一起发送。谢谢!
func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
print("url \(url)")
print("url host :\(url.host as String?)")
print("url path :\(url.path as String?)")
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
if(url.host == "/details"){
let Ads_details: CollectionDetailViewController = mainStoryboard.instantiateViewController(withIdentifier: "CollectionDetailViewController") as! CollectionDetailViewController
self.window?.rootViewController = Ads_details
} else if (url.host == "/profile"){
let User_profil: UserProfileViewController = mainStoryboard.instantiateViewController(withIdentifier: "UserProfileViewController") as! UserProfileViewController
self.window?.rootViewController = User_profil
}
self.window?.makeKeyAndVisible()
return true
}
解决方案
推荐阅读
- git - 用于 github 更改版本控制文件的自动合并脚本
- asp.net - 无法从母版页访问服务器端变量
- javascript - 将 Python 函数返回到 Chrome 控制台
- android-studio - setScaleX / setScaleY 为十进制值
- python - doxc 样式列表段落
- python-3.x - 如何找出六位连续数字(例如 123456、345678 和 789012)是否出现在给定字符串的任何位置
- push-notification - 通过硬编码开发推送服务
- javascript - 有没有办法重新 webapck npm 包,使用 webpacked 的 wasm 并将其用于 vscode 插件开发?
- javascript - 如何在 Javascript-Jquery 的两个输入中将 HH:MM 时间的小时和分钟相加?
- typescript - 将 ...args 映射到子类型的元组