首页 > 解决方案 > 如何在 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
}

标签: iosswiftxcode9deep-linkingappdelegate

解决方案


推荐阅读