iOS 中的延迟深度链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25855618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:28:12  来源:igfitidea点击:

Deferred Deep Linking in iOS

iosdeep-linking

提问by Kiran Panesar

We're trying to implement deferred deep linking in one of our iOS applications to encourage users to invite their friends to use the app, and reward users based on how many installs occur from their referral link. Basically similar to TapStream's product.

我们正在尝试在我们的一个 iOS 应用程序中实施延迟深度链接,以鼓励用户邀请他们的朋友使用该应用程序,并根据用户推荐链接的安装次数来奖励用户。基本类似于TapStream 的产品

Consider this example:

考虑这个例子:

So, UserA shares their link, “ourappURL.com/refer?id=userA”, on any network they want. UserB clicks that link, which will take them to Safari and then bounce them to the App Store page where UserB downloads the app.

When UserB opens the app, the app checks which referral ID they came in on (if any). In this example, the referral ID would be “userA” as that's the ID that was in the referral link. The app then sends this to our servers and we award UserA with a referral credit.

因此,用户 A 在他们想要的任何网络上共享他们的链接“ourappURL.com/refer?id=userA”。用户 B 单击该链接,这会将他们带到 Safari,然后将他们退回到用户 B 下载应用程序的 App Store 页面。

当用户 B 打开应用程序时,应用程序会检查他们进入的推荐 ID(如果有)。在此示例中,推荐 ID 将是“userA”,因为这是推荐链接中的 ID。然后应用程序将其发送到我们的服务器,我们会向 UserA 授予推荐积分。

I'm trying to break this issue down into its core parts. I believe the first part is getting the web page for the user's referral link to save the referral ID to the device somewhere that the app can access it. But I'm not sure this is possible because of the sandboxed nature of iOS.

我试图把这个问题分解成它的核心部分。我相信第一部分是获取用户推荐链接的网页,以将推荐 ID 保存到应用程序可以访问的设备的某个位置。但由于 iOS 的沙盒特性,我不确定这是否可行。

I know this is fundamentally possible because many ad providers offer the ability to track installations from an ad campaign (see Mobile App Tracking for example).

我知道这从根本上是可能的,因为许多广告提供商都提供从广告活动跟踪安装的功能(例如,请参阅移动应用跟踪)。

采纳答案by ethangui

We have also attempted to do this ourselves and I will try to break down the different steps here.

我们也尝试过自己这样做,我将尝试分解这里的不同步骤。

Going back to your example, you are correct about "remembering" the device identification, and all relevant data "id=userA". You are also correct about "sandboxed nature of iOS" which I presume it means a web page is not allowed to store information outside of the browser app (Safari) and apps (your app) are not able to access information stored by other apps (Safari).

回到您的示例,您对“记住”设备标识和所有相关数据“id=userA”是正确的。您对“iOS 的沙盒特性”的看法也是正确的,我认为这意味着网页不允许在浏览器应用程序 (Safari) 之外存储信息,并且应用程序(您的应用程序)无法访问其他应用程序存储的信息(苹果浏览器)。

Our solution to this is to store this device to data key-value pair in an environment that is both accessible by the browser as well as by your app, i.e. your backend server.

我们对此的解决方案是在浏览器和您的应用程序(即您的后端服务器)都可以访问的环境中将此设备存储为数据键值对。

The next challenge, which remains to be the biggest challenge, is how to uniquely identify this device from the information collectable from the browser? Javascripts in browsers, unlike native apps, don't have access to IDFAs which could be used to uniquely identify a iOS device. To overcome this, one can imagine to use a combination of common information that is available both to the browser app as well to your native app, i.e. OS type, public IP, screen size, etc. etc. Please note, a composite key from these data fields does not guarantee uniqueness (imagine two iPhone 6 visiting this web page via the same router). Therefore, your backend server (assuming you are using it to store this key-value pair), will want to have a strategy on how to handle collisions on keys i.e. the second key deletes the first key, or you allow collision to exist by having a queue of values for a single key. This really depends on how you actual plan to use this technology.

下一个挑战,仍然是最大的挑战,是如何从浏览器收集的信息中唯一识别该设备?与本机应用程序不同,浏览器中的 Javascript 无法访问可用于唯一标识 iOS 设备的 IDFA。为了克服这个问题,可以想象使用浏览器应用程序和您的本机应用程序都可以使用的公共信息的组合,即操作系统类型、公共 IP、屏幕大小等。请注意,来自这些数据字段不保证唯一性(假设两台 iPhone 6 通过同一路由器访问此网页)。因此,您的后端服务器(假设您正在使用它来存储此键值对)将需要一个关于如何处理键冲突的策略,即第二个键删除第一个键,或者您可以通过为单个键创建一个值队列来允许冲突存在。这实际上取决于您实际计划如何使用这项技术。

The last step is to form this composite key on your app using the exact same fields you used earlier in the browser to perform a "lookup" on your backend server to retrieve the value previously stored.

最后一步是使用您之前在浏览器中使用的完全相同的字段在您的应用程序上形成此复合键,以在后端服务器上执行“查找”以检索先前存储的值。

Here is a summary of the steps:

以下是步骤的摘要:

  1. User 1 invites User 2 by sending the following link to 2: example.com?inviter=1
  2. User 2 visit Web Page P
  3. P constructs and sends the following key-value pair to your server S iOS|55.55.55.55|750×1334 -> inviter_id=1
  4. User 2 goes to the app store and downloads your App A
  5. Upon 2 first launches A, A contacts S with the same key (assuming the IP hasn't changed).
  6. S finds the value inviter_id=1 by using this key passed in and, let's say, reward User 1 five points for inviting 2.
  1. 用户 1 通过向用户 2 发送以下链接来邀请用户 2:example.com?inviter=1
  2. 用户 2 访问网页 P
  3. P 构建并发送以下键值对到您的服务器 S iOS|55.55.55.55|750×1334 -> inviter_id=1
  4. 用户 2 前往应用商店并下载您的应用 A
  5. 在 2 首次启动 A 时,A 使用相同的密钥联系 S(假设 IP 没有改变)。
  6. S 通过使用传入的此密钥找到值 inviter_id=1,假设用户 1 因邀请用户 2 而奖励 5 分。

Hope this help!

希望这有帮助!

Edit 04/24:

编辑 04/24:

Since Derrick mentioned it in the comments, I figure I would take this chance to finish our story here.

既然戴里克在评论中提到了,我想我会借此机会在这里结束我们的故事。

Going back to the beginning of my answer where I mentioned we've attemptedto do this ourselves. We had a working prototype based on our current system architecture (which is not in anyway optimized, or meant to be optimized, for storing and analyzing deep link data like this), we ultimately decided not to allocate any additional engineering resource into this project.

回到我回答的开头,我提到我们已经尝试自己做这件事。我们有一个基于我们当前系统架构的工作原型(无论如何都没有优化或打算优化,用于存储和分析这样的深度链接数据),我们最终决定不向该项目分配任何额外的工程资源。

Due to the heuristic nature of this matching process, we found this project needing debugging, tuning and optimizing constantly for a diminishing ROI. More importantly, we have found other companies which are more specialized and do a much better job than ourselves.

由于此匹配过程的启发式性质,我们发现该项目需要不断调试、调整和优化以降低 ROI。更重要的是,我们发现了其他比我们更专业、做得更好的公司。

It has been probably 6 months since we stopped using our internal system and we haven't regretted making such decision.

我们停止使用我们的内部系统已经有大约 6 个月了,我们并不后悔做出这样的决定。

During this processes, we've worked with a number of vendors, Appsflyer, Adjust, TapStream and we have ultimately ended up with Branch Metrics https://branch.io.

在此过程中,我们与许多供应商、Appsflyer、Adjust、TapStream 合作,最终我们得到了 Branch Metrics https://branch.io

Whether you should DIY or work with another company again depends on your specific objective. We finally decided to stay with Branch, not only because the other vendors charged anywhere from $500 to thousands of dollars per month while Branch is completely free, but also the level of the support they have provided is simply unparalleled.

您是否应该DIY或再次与另一家公司合作取决于您的具体目标。我们最终决定留在 Branch,这不仅是因为其他供应商每月收费从 500 美元到数千美元不等,而 Branch 是完全免费的,而且他们提供的支持水平也是无与伦比的。

回答by PPierson

There is a good solution here: http://blogs.innovationm.com/deferred-deep-linking-in-ios-with-universal-link/

这里有一个很好的解决方案:http: //blogs.innovationm.com/deferred-deep-linking-in-ios-with-universal-link/

Basic workflow:

基本工作流程:

  • User selects domain link on web.
  • Link sets referral ID to cookie.
  • User redirected to app store.
  • On app launch, load referral page in SFSafariViewController.
  • Referral page checks for cookie and if it exists calls a deeplink into the app with the referral ID.
  • 用户在网络上选择域链接。
  • 链接将推荐 ID 设置为 cookie。
  • 用户重定向到应用商店。
  • 在应用程序启动时,加载 SFSafariViewController 中的推荐页面。
  • 推荐页面检查 cookie,如果存在,则使用推荐 ID 调用应用程序的深层链接。

回答by Anthony Scott

We've successfully used the clipboard (NSPasteboard) to achieve this: the web page that processes the redirect to the app store does a paste to the mobile device's clipboard before letting the user download the app. Once the app is installed, it uses NSPasteboard on first launch to check for an appropriately coded string. This string can contain the text of interest or, more securely, a token used to fetch interesting data from the backend. In Objective C:

我们已经成功地使用剪贴板 (NSPasteboard) 来实现这一点:在让用户下载应用程序之前,处理重定向到应用商店的网页会粘贴到移动设备的剪贴板。安装应用程序后,它会在首次启动时使用 NSPasteboard 来检查适当编码的字符串。该字符串可以包含感兴趣的文本,或者更安全地,包含用于从后端获取感兴趣数据的令牌。在目标 C 中:

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *pasteboardString = pasteboard.string;

The clipboard can be cleared once the app is done with it, to avoid repeating the same action.

应用程序完成后可以清除剪贴板,以避免重复相同的操作。

回答by devtech

My answer from HERE

我的回答来自这里

Apple no longer supports Deep Links. It is now called Universal Links and works a bit differently.

Apple 不再支持 Deep Links。它现在被称为通用链接,工作方式略有不同。

Source

来源

Now that Apple no longer supports URI schemes for deep linking, developers must implement Universal Links in order to deep link properly on iOS. If you are already using URI schemes, check out our blog on transitioning to Universal Links.

现在 Apple 不再支持深度链接的 URI 方案,开发人员必须实现通用链接才能在 iOS 上正确地进行深度链接。如果您已经在使用 URI 方案,请查看我们关于过渡到通用链接的博客。

From: HERE

来自:这里

And HEREis another article on Universal Links and what they are.

这里是通用的链接和他们是什么另一篇文章。