菜鸟教程小白 发表于 2022-12-11 18:26:46

ios - 从链接打开应用程序时,appsflyer 深层链接不起作用(未调用委托(delegate)方法)


                                            <p><p>我使用 AppFlayer SDK 进行了深度链接,并且通用链接成功打开了应用程序,这意味着深度链接工作正常。 </p>

<p>现在的问题是 <strong>当应用程序从链接打开时,它不会重定向到它的页面。但是,如果我将应用程序放在后台并放在前台,那么深度链接就可以工作</strong> </p>

<p>我遵循此指南。( <a href="https://support.appsflyer.com/hc/en-us/articles/208874366-OneLink-Integration-Guide-Version-1-1" rel="noreferrer noopener nofollow">link</a> )</p>

<p><em>AppFlayer 设置代码</em></p>

<pre><code>func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: ? = nil) -&gt; Bool {
      AppsFlyerTracker.shared().appsFlyerDevKey = &#34;xxxxxxxxxxxx&#34;
      AppsFlyerTracker.shared().appleAppID = &#34;xxxxxxx&#34;
      AppsFlyerTracker.shared().isDebug = false
      AppsFlyerTracker.shared().delegate = self

      self.pushNotificationService(application)

      objStoryBoard = UIStoryboard(name:&#34;Main&#34;, bundle: nil)

      return true
    }
</code></pre>

<p><em>AppFlayer 委托(delegate)</em> </p>

<blockquote>
<p>Edit :: This method not called when application is open from link of appsflayer marketing</p>
</blockquote>

<pre><code>//MARK:
      //MARK: appflayer delegate
      func onAppOpenAttribution(_ installData: ) {

      NSLog(&#34;installData ::%@&#34;, installData )

      if let link = installData[&#34;link&#34;] as? String
      {
            if link.contains(read_Localizable(&#34;titleAppflayer&#34;))
            {
                if let arrQueryItems = URLComponents(string: link)!.queryItems {

                  for obj in arrQueryItems {
                        if obj.name.caseInsensitiveCompare(read_Localizable(&#34;appflayerParameter&#34;)) == .orderedSame
                        {
                            self.redirectAppflayer(withstrUrl: obj.value!)
                            return
                        }
                  }
                }
            }
      }
    }
</code></pre>

<p>应用的用户事件方式</p>

<pre><code>func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping (?) -&gt; Void) -&gt; Bool {

//      if let url = userActivity.webpageURL
//      {
//            NSLog(&#34;URL :: %@&#34;,)
//      }

      if userActivity.webpageURL?.absoluteString.contains(read_Localizable(&#34;titleAppflayer&#34;)) == true
      {
            AppsFlyerTracker.shared().continue(userActivity, restorationHandler: restorationHandler)
            return true
      }

      return Branch.getInstance().continue(userActivity)
    }
</code></pre>

<p>让我知道我做错了什么。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您正在从 <code>willFinishLaunchingWithOptions</code> 调用 AppsFlyerTracker,而应该从 <code>didFinishLaunchingWithOptions</code> 调用它。能不能把相关代码挪一下再测试一下?</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 从链接打开应用程序时,appsflyer 深层链接不起作用(未调用委托(delegate)方法),我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/45523157/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/45523157/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 从链接打开应用程序时,appsflyer 深层链接不起作用(未调用委托(delegate)方法)