我使用 AppFlayer SDK 进行了深度链接,并且通用链接成功打开了应用程序,这意味着深度链接工作正常。
现在的问题是,当应用程序从链接打开时,它不会重定向到它的页面。但是如果我把应用程序放在后台并放在前台,那么深度链接就可以了
我遵循此指南。(链接)
AppFlayer 设置代码
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
AppsFlyerTracker.shared().appsFlyerDevKey = "xxxxxxxxxxxx"
AppsFlyerTracker.shared().appleAppID = "xxxxxxx"
AppsFlyerTracker.shared().isDebug = false
AppsFlyerTracker.shared().delegate = self
self.pushNotificationService(application)
objStoryBoard = UIStoryboard(name:"Main", bundle: nil)
return true
}
AppFlayer 委托
编辑 :: 从appsflayer营销链接打开应用程序时不调用此方法
//MARK:
//MARK: appflayer delegate
func onAppOpenAttribution(_ installData: [AnyHashable: Any]) {
NSLog("installData ::%@", installData )
if let link = installData["link"] as? String
{
if link.contains(read_Localizable("titleAppflayer"))
{
if let arrQueryItems = URLComponents(string: link)!.queryItems {
for obj in arrQueryItems {
if obj.name.caseInsensitiveCompare(read_Localizable("appflayerParameter")) == .orderedSame
{
self.redirectAppflayer(withstrUrl: obj.value!)
return
}
}
}
}
}
}
应用程序的用户活动方法
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
// if let url = userActivity.webpageURL
// {
// NSLog("URL :: %@",[url])
// }
if userActivity.webpageURL?.absoluteString.contains(read_Localizable("titleAppflayer")) == true
{
AppsFlyerTracker.shared().continue(userActivity, restorationHandler: restorationHandler)
return true
}
return Branch.getInstance().continue(userActivity)
}
让我知道我做错了什么。