<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Konstantin Yakushev on Medium]]></title>
        <description><![CDATA[Stories by Konstantin Yakushev on Medium]]></description>
        <link>https://medium.com/@kojoru?source=rss-e869ba44285f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*x3FxeD6Qww6mDRlNSYgfVg.jpeg</url>
            <title>Stories by Konstantin Yakushev on Medium</title>
            <link>https://medium.com/@kojoru?source=rss-e869ba44285f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 20:01:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kojoru/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to set up merge queues in GitHub Actions]]></title>
            <link>https://medium.com/@kojoru/how-to-set-up-merge-queues-in-github-actions-59381e5f435a?source=rss-e869ba44285f------2</link>
            <guid isPermaLink="false">https://medium.com/p/59381e5f435a</guid>
            <category><![CDATA[merge-queue]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Konstantin Yakushev]]></dc:creator>
            <pubDate>Fri, 18 Aug 2023 00:57:50 GMT</pubDate>
            <atom:updated>2023-08-21T09:21:04.607Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="A queue of cars trying to merge into a parking garage" src="https://cdn-images-1.medium.com/max/1024/1*1_ZYfJvvX1JWN-Ts5b4Q9Q.jpeg" /></figure><p>GitHub Merge Queues is a cool feature for repositories that have a long-running CI and a lot of pull requests requiring that CI.</p><p>GitHub talks about that feature at length <a href="https://github.blog/2023-07-12-github-merge-queue-is-generally-available/">in their blog post</a>, but the gist of it is that it allows you to run CI actions on multiple PRs at the same time stacked on top of each other. This allows you to remove the annoying “upmerge main” step you otherwise continuously need to do when other people’s pull requests are merged before yours.</p><p>Unfortunately, the documentation for how to integrate GitHub Merge Queues with GitHub Actions is not entirely straightforward and misses some details you’ll be scrambling to figure out on your own. Luckily, I already did, so I can present it to you in this explainer-slash-tutorial.</p><p>The explainer-slash-tutorial comes in two parts: explainer and tutorial.</p><h3>Explainer: how does CI for Merge Queues work</h3><p>The merge queues are based on two other features of GitHub you’ll need to understand first: branch protection rules and automerging of pull requests.</p><p><strong>Branch protection rules</strong> allow you to force a certain set of ceremonies around merging to your branch. For example, you can forbid directly pushing to main or force a CI run before merging. If you are looking into merge queues, you probably have both of those already enabled.</p><p>The merge queues themselves are also a form of branch protection so this is a new checkbox you’ll need to enable in that interface.</p><p><strong>Automerging </strong>is a feature on top of the protection rules. It allows you to press the “Merge” button before the CI is finished, and the merge will be performed when/if it’s successful.</p><p><strong>Merge queues </strong>surprisingly do not replace the CI step before the automerge, but instead adds a separate later step to it. So, the end flow looks like that:</p><ol><li>A pull request is created.</li><li>CI runs on the pull request’s unmerged code.</li><li>At any point before, during or after the CI run the PR is marked for merge.</li><li>If the CI succeeded, the pull request is put in the merge queue.</li><li>In the merge queue, a separate CI is run on the merged code.</li><li>If that succeeds, the pull request is merged (provided the rest of the queue also got merged before that).</li></ol><p>Thus, when implementing the build queue, you need to think what checks you need to do before the PR even gets in the queue, and what checks you need to do in the queue.</p><p>The simple option is to just do a full CI run both times, but other options are possible such as:</p><ul><li>having smoke tests in the “pre-queue” CI and full tests in the “queue” CI</li><li>skipping “pre-queue” altogether and only running the CI in the queue</li></ul><p>I’ll explain how to proceed if you want either of those options in the next section.</p><h3>Tutorial: how to set up a CI for Merge Queues</h3><p>Firstly, you need to have a repository that is either a private repository in a GitHub Enterprise-licensed organization or a public repository in any organization. Personal repositories don’t support that feature at all, even public ones or if you have a Pro subscription.</p><p>Secondly, you’ll need some workflows. This is nice to set up before branch protection so that we can point to the existing workflow then.</p><p>We’ll need to create a pull request (pre-queue) workflow and a queue workflow.</p><p>Pull request, (e. g. put it in .github/workflows/pull-request.yml):</p><pre>name: Validate pull request before putting into queue<br><br>on:<br>  pull_request:<br><br>jobs:<br>  validate-pr:<br>    runs-on: ubuntu-latest<br>    steps:<br>    - name: Checkout code<br>      uses: actions/checkout@v3<br>    - name: Display info<br>      run: | <br>        pwd<br>        tree -a -I &#39;.git&#39;<br>        git status<br>    - name: Run fast CI (emulated by a short sleep)<br>      run: sleep 5</pre><p>Merge queue, (e. g. put it in .github/workflows/merge-queue.yml):</p><pre>name: Validate code in the merge queue<br><br>on:<br>  merge_group:<br><br>jobs:<br>  validate-pr:<br>    runs-on: ubuntu-latest<br>    steps:<br>    - name: Checkout code<br>      uses: actions/checkout@v3<br>    - name: Display info<br>      run: | <br>        pwd<br>        tree -a -I &#39;.git&#39;<br>        git status<br>    - name: Run slow CI (emulated by a long sleep)<br>      run: sleep 300</pre><p>The are two important parts here:</p><ol><li>The way the workflows are distinguished are via event names. merge_group event is <a href="https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group">a new trigger</a> that is tied to a new pull request being put to the queue.</li><li>The job name (validate-pr in both workflows) is important because it will be used to tie the workflows to the branch protection later. There’s no way to set different required status checks to a pre-queue and a post-queue run, so they’ll need to be named the same. This way they look like the same job to GitHub.</li></ol><p>Finally, you need to set branch protection rules. Go to Settings → Branches and create or modify the rules for your trunk branch. You’ll need to enable “Require status checks to pass before merging” (select “validate-pr” as the required check) and “Require merge queue”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*INNVC0r0lSA2pZX01Sn3OA.png" /></figure><p>That should be enough to get you started. Now when you create a pull request that starts the pull request CI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*w9I6THnD2Po-kiJk41OgLQ.png" /></figure><p>You can click “Merge when ready” either before or after that is finished. This will place the pull request in the queue and run the queue CI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_05CsJ7m_th91odOSQdXVA.png" /></figure><h4>Other options for CI split</h4><p>If you’d like to have the same CI running both before the queue and after, you can just use one workflow, along these lines:</p><pre>name: Validate code<br><br>on:<br>  merge_group:<br>  pull_request:<br><br>jobs:<br>  validate-pr:<br>    runs-on: ubuntu-latest<br>    steps:<br>    - name: Checkout code<br>      uses: actions/checkout@v3<br>    - name: Display info<br>      run: | <br>        pwd<br>        tree -a -I &#39;.git&#39;<br>        git status<br>    - name: Run slow CI (emulated by a long sleep)<br>      run: sleep 300</pre><p>If you’d like to run nothing before the merge queue, that is not possible or I haven’t found how. So you’ll need to modify the pull-request.yml to do <em>almost </em>nothing, along these lines:</p><pre>name: Skip validating pull request before putting into queue<br><br>on:<br>  pull_request:<br><br>jobs:<br>  validate-pr:<br>    runs-on: ubuntu-latest<br>    steps:<br>    - name: Skip run<br>      run: echo &quot;Run skipped&quot;</pre><h3>Link</h3><p>There’s a sample repository I used to test the above. You can access it here: <a href="https://github.com/kojoru-sandbox/MergeQueues">kojoru-sandbox/MergeQueues (github.com)</a></p><p>Good luck and happy queueing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59381e5f435a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Universal links for Android and iOS]]></title>
            <link>https://medium.com/bumble-tech/universal-links-for-android-and-ios-1ddb1e70cab0?source=rss-e869ba44285f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ddb1e70cab0</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[deep-linking]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[universal-links]]></category>
            <dc:creator><![CDATA[Konstantin Yakushev]]></dc:creator>
            <pubDate>Thu, 23 Aug 2018 14:33:20 GMT</pubDate>
            <atom:updated>2018-08-23T18:22:08.265Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h4>Making them work (almost) every time</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ut2FSlvmwmiLKrLKaumCNA.jpeg" /><figcaption>Sharing between platforms should always work</figcaption></figure><p>Mobile apps have given a huge amount of good things to the human race, but at the same time, they have broken the internet. Instead of easy-to-understand links to sites which can be copied and shared, now you have to tell people what app to use to access which content.</p><p>Theoretically this was fixed by both Google and Apple, several times. The marketing description says that if everything is set up properly, when your user taps a link, it’s opened exactly where it’s intended to open, be it a website or an app. You just need to set up your websites and apps in a few easy steps.</p><p>If you are a developer, you are probably guessing that making it just right would be somewhat tedious. In practice, you have no idea. There are dragons lurking around that are undocumented and yet pretty fire-breathing. At Badoo we’ve encountered, tagged and catalogued most of them and are prepared to share the knowledge with you.</p><p>I coordinated Badoo’s deep linking efforts on Android, iOS and web. This article is based on a talk I gave in Russian at Mobius conference. If you understand Russian, you can <a href="https://www.youtube.com/watch?v=Vb28IRC8c6o">watch the video</a> or <a href="https://habr.com/company/jugru/blog/352914/">read a similar article in Russian</a>. I will mostly talk about iOS because that’s where you’re going to encounter most of the problems and weird shenanigans, but a few of our Android hacks are mentioned as well.</p><p>This article is very long. If you feel you just want to jump straight to action, just go directly to the <a href="https://medium.com/p/1ddb1e70cab0#4394">tl;dr</a> part at the end.</p><h3>Table of Contents</h3><ul><li><a href="https://medium.com/p/1ddb1e70cab0#4110">What a universal link is and why you need it</a></li><li><a href="https://medium.com/p/1ddb1e70cab0#9a02">How we implemented the deep links</a></li><li><a href="https://medium.com/p/1ddb1e70cab0#6f12">How deep links work, the very beginning</a></li><li><a href="https://medium.com/p/1ddb1e70cab0#42e8">How we added support for universal links to an iOS app</a></li><li><a href="https://medium.com/p/1ddb1e70cab0#d324">How we minified universal links</a></li><li><a href="https://medium.com/p/1ddb1e70cab0#d6b4">How deferred deep links work</a></li><li><a href="https://medium.com/p/1ddb1e70cab0#7e04">How nothing works in SafariViewController</a></li><li><a href="https://medium.com/p/1ddb1e70cab0#a08e">What the system looks like with web preview</a></li><li><a href="https://medium.com/p/1ddb1e70cab0#fe51">How we encountered mysterious bugs and solved them</a></li><li><a href="https://medium.com/p/1ddb1e70cab0#2d64">How to version deep links</a></li><li><a href="https://medium.com/p/1ddb1e70cab0#4255">How we tamed Facebook</a></li><li><a href="https://medium.com/p/1ddb1e70cab0#7e76">When we still use old-style links</a></li><li><a href="https://medium.com/p/1ddb1e70cab0#4394">How to do universal links, tl;dr</a></li></ul><h3>What a universal link is, and why you need it</h3><p>What are universal links in the first place? The story is quite straightforward.</p><p>You are using an application, let’s say Badoo. Say you see a beautiful person there. You immediately want to show their awesomeness to your friend. So you press a button and share a link:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/0*VWGdQM7bqCXDMtxf" /></figure><p>You send your friend the link. It displays nicely in the message, your friend clicks on it and they open up the page with the same girl:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*CWus1KxjOrXc6rRy" /></figure><p>When the link opens content inside an application, this is traditionally referred to as deep linking, and the link as a <strong>deep link</strong>. However, this is an ideal scenario, assuming your friend has the app already installed and is using iOS.</p><p>If that’s not the case, we might want this same link to have other features as well, e. g.:</p><ul><li>Opening the app on other platforms with the same content (e. g. on android)</li><li>Opening the app store if the app is not installed</li><li>Showing the web version if we don’t want to force installation of the app or if the link is opened on an unsupported platform (e. g. on windows/mac)</li></ul><p>If a link has all these features, or at least some of them, it is called a <strong>universal link</strong>. The thorny path of creating and fine-tuning these beasts is what I want to tell you about.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*80_ycWBTQoUh5n6O" /></figure><p>This is what it looks like step-by-step. If a link is opened from the desktop, we open the desktop web. If it’s opened from a smartphone, we look to see whether the app in question has been installed and, depending on the answer, we either open the link in the app or we direct the user to the app store. If the user is directed to the app store, we’d love to open the originally requested content after the installation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WSYkCwoFGc7hymM_" /></figure><p>Why would you need to do any of this? We found out there are millions of scenarios. Let me show you a few examples.</p><p>Suppose you want to send a message to a user, saying, “Look, you’ve got a new ‘like’.” It would be great if, by clicking on ‘Take a look’, you could open up that exact ‘like’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/0*FkO2RfC5FHWXk8wJ" /></figure><p>Another example: the pop band ‘Serebro’ registered an account in your application. You want them to be able to publish a link under their videos which would also open up this profile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*ZqdGnQlpKMVxrUT1" /></figure><p>Other useful use case is ads in Facebook. Facebook is very sensitive about ensuring that, if something specific is displayed in an ad, the link in question directs the user to that ‘something’. So, if in an ad you see the profile for a guy, they insist that you should be able to see that same guy in the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oOCSI2FsT0rLJSQ7" /></figure><p>But the coolest example is typically the ‘share’ button.</p><p>The great thing about this button is that users actually want to spread some information related to your application. It is even more common for applications other than dating.</p><p>Let’s say you have a travel application. Users will voluntarily and happily share their tickets or hotels with their companions. They will send links to their friends, thus advertising your application at no cost to you. Ideally, this leads to new installs and organic growth — and the only thing you have to pay for is the one-time implementation of deep links.</p><h3>How we implemented the deep links</h3><p>We realised this was great and we were keen to have it. So, we got together and started to think about how we could do it.</p><p>There are several options available:</p><ul><li>branch.io (a staple name, everyone knows them),</li><li>AppsFlyer (a marketing juggernaut),</li><li>some other small weird services (we didn’t actually look into them and Firebase Deep linking didn’t exist back then), or</li><li>you can make your own (reinventing the wheel, as it were).</li></ul><p>In the end we decided to reinvent the wheel, but let me tell you how it came to that.</p><h4>Branch.io</h4><p>The first thing we did was to look at <a href="https://branch.io/">branch.io</a>. Without exception, everything they do is related to deep links: right at the centre of the site are the words ‘deep linking’. The two points on either side basically also pretty much mean deep linking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*7-XK3kSxd2udegd8" /></figure><p>They have loads of well known clients; our dearly beloved rival, Tinder, uses them. And, for some use cases, they are free-of-charge. However, in our case they turned out to be not quite so free-of-charge.</p><p>They are, there’s no question about it, experts in the field. They write a million blog posts in which they tell you about the very same problems which I am going to tell you about. However, once their posts go from describing the problem to talking about the solution, they fudge the issue somewhat and say, “Use our service; we know how it’s done.” Which is a boring non-answer. Luckily, now you have me, and I have the non-boring right answers!</p><h4>AppsFlyer</h4><p><a href="https://www.appsflyer.com/">AppsFlyer</a> is a marketing service intended first and foremost for tracking installations with a specific focus on finding the origin where the user has come from. This means measuring the effectiveness of advertising campaigns and things like that. When we started working on universal links, Badoo was already their client and our marketing people simply adored it. If you were to corner one of our marketing people and ask them whether AppsFlyer is good, this is the answer you would get, “Very good; all other services are far worse. And please don’t corner me. Thank you.”</p><p>AppsFlyer also has lots of well known clients; Tinder also uses AppsFlyer for everything but deep linking, but at the time this didn’t put us off.</p><p>We went onto the site and saw the notice, “The world’s most powerful deep linking platform.” Okay, based on our thorough assessment of this incredibly detailed marketing copy, it looked like that was exactly what we needed.</p><p>What’s more, at the time for us it was free-of-charge, because it was part and parcel of another product for which we were already paying (unlike branch.io which can become very expensive, depending on how you use them).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IYISjkWL81XUgNBI" /></figure><p>We went onto their site. At the time, they had this diagram which isn’t on the site anymore. Basically, it is what I showed earlier. You follow the link. If the app is installed, it runs. If it isn’t installed, you go to the App Store. But…</p><p>It turned out that in the case where the application is not installed, we go to the App Store and, having installed it, we open the content — and it works. And that makes sense; those guys do install tracking, it’s their job.</p><p>However, in the case where the application is already installed, for some reason instead of opening the content, it again displays the question, “Open this page in App Store?”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SwmzqkzYQl1vS3lX" /></figure><p>That is when we stopped blindly following SDK instructions and sat down to figure out how it works under the hood. And, in order to work out why they have this error and what we could do about it, we had to start at the very beginning.</p><h3>How deep links work, the very beginning</h3><p>Here is a deep link that you probably would consider a totally standard one:</p><pre>badoo://user/1234567</pre><p>Here we have the custom scheme badoo://, a reference to something we want to open (user in that case) and the ID of the content in question (1234567).</p><p>Obviously, you can’t use this link in its ‘raw’ form for a very simple reason. If the application is installed, it works as a link, but if the application is not installed, it leads to the error message such as “Safari cannot open the page.” That makes sense: Safari has no idea how to work with it.</p><p>Until recently this could be fixed by a pretty simple hack. We made a typical HTML page that looked similar to this:</p><pre><a href="https://example.com/user/1234567">https://example.com/user/1234567</a></pre><pre>&lt;html&gt;<br>&lt;head&gt;<br>  …<br>&lt;/head&gt;</pre><pre>&lt;body&gt;<br>  &lt;iframe src=&quot;<strong>badoo://user/1234567</strong>&quot;&gt;<br>  &lt;script&gt;<br>    <strong>// redirect to app store<br>  </strong>&lt;/script&gt;</pre><pre>&lt;/body&gt;</pre><pre>&lt;/html&gt;</pre><p>There is an iframe, which receives parameters from the URL and which contains the deep link as source. And there is a javascript snippet which redirects to the App Store. The idea is that if you have the app installed, iframe will run first and take you to the app, and if you don’t, the redirect kicks in and everyone is happy and you see no errors.</p><p>Besides that, you can attach Open Graph tags to the HTML page, which will allow the link to look attractive, just as I showed you: it has an image, a preview and everything.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/0*jym9K69xxTXfmZsH" /></figure><pre><a href="https://example.com/user/1234567">https://example.com/user/1234567</a></pre><pre>&lt;html&gt;<br>  &lt;head&gt;<br>   <strong> &lt;meta property=&quot;og:image&quot; content=…&gt;<br>    &lt;meta property=“og:title&quot; content=…&gt;</strong><br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    …<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>Right, so starting from about iOS 9, this simple approach simply stopped working.</p><p>What do I mean by ‘stopped working’? I mean that it started working as if you were simply dealing with the badoo:// link. If the application was installed, it worked. If it was not installed, it showed an error (basically, on top of the redirect). In other words, if the user follows the link and they don’t have the application installed, an error occurs. And at Apple they ‘broke’ this deliberately.</p><p>Why? Because they came up with something they claimed was fundamentally new and fantastic, namely universal links.</p><p>Their idea was that you would simply register the entire link, the whole domain, as a universal link. And when I say that this was a fundamentally new and fantastic approach, I in fact mean ‘almost fundamentally new’ because Android has had it for a number of years already.</p><p>So this way http://example.com/user/1234567 becomes a link registered with the application (both iOS and Android)</p><p>Why did Apple make this change?</p><ul><li>Verification. Any app can claim to support badoo://. The domain however is confirmed by the DNS.</li><li>Privacy. The application no longer has access to cookies from the original website and its partners. This is what Apple has been focusing on more and more with every passing year: to separate knowledge about the user in Safari from knowledge about the user in the application.</li><li>Simplicity. In theory, this will remove the need for iframe hacks.</li><li>Versatility. This approach is supposed to work better across all possible platforms.</li></ul><p>Unfortunately, the ‘Simplicity’ part didn’t hold up for us one bit. Once we had got rid of iframe hacks, we were forced to add lots of other hacks — but more about that later.</p><p>For now, let’s go back to AppsFlyer. Remember, it all started with the fact that they didn’t support universal links.</p><p>In fact, as we learned from the documentation, they did support universal links, but they only supported them with a third-level domain of their own.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VLLugk-mO8PWIhjE" /></figure><p>At Badoo we really don’t like to take such risks. Theoretically AppsFlyer could increase their price tenfold or simply close down the shop, and the links are already distributed all around the internet. We wanted to be able to support the links forever, regardless of our partners’ behaviour.</p><p>But we know how to solve these problems in the web, right? We’ll just do a redirect. After all, redirects already work on the web, right?</p><p>https://badoo.com/link/user/1234567<br>redirects to<br>https://badoo.onelink.me/user/1234567</p><p>And we started testing. Okay, onelink.me works; everything is integrated fine. SDK runs, opens Badoo and opens content. Our link, which is a totally standard redirect… opens Safari. “No way,” we thought.</p><p>https://badoo.com/link/user/1234567 — opens Safari</p><p>https://badoo.onelink.me/user/1234567 — opens Badoo</p><p>We started investigating and found out the reason. Also, at this point we started keeping a list which was destined to grow longer and longer as our investigation progressed. The list is called, ‘When universal links don’t open the application even though you’d reasonably expect them to.’</p><p>And here is the first point on the list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-QuBJTtGPfyDM7QQ" /></figure><p>Redirects to universal links generally do not work. This really bummed us and we decided to completely give up on AppsFlyer (for this reason — and some others) and do everything ourselves. We particularly liked that idea because we already had https-links that we used with Android:</p><p>https://m.badoo.com/aa/landto/?page=9&amp;user_id=1234567</p><p>It consisted of a weird legacy URL and two parameters: page id (i. e. which screen to open, here it’s 9) and content id (e. g. user id, here it’s 1234567).</p><h3>How we added support for universal links to an iOS app</h3><p>Adding support for a universal link on iOS isn’t particularly complicated. There are<a href="https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html"> instructions</a> on the Apple site, which literally take three pages if printed and basically tell you to do three things.</p><p>Firstly, you need to add an apple-app-site-association JSON file with your appID and the paths the application should open to the universal links. Here’s how it looked for us:</p><pre><a href="https://m.badoo.com/apple-app-site-association">https://m.badoo.com/apple-app-site-association</a></pre><pre>{<br>  &quot;applinks&quot;: {&quot;apps&quot;: [],<br>    &quot;details&quot;: [<br>      {<br>        &quot;appID&quot;: &quot;KNH8H96PY6.com.badoo.Badoo&quot;,<br>        &quot;paths&quot;: [&quot;/aa/*&quot;]<br>      }<br>    ]<br>  }<br>}</pre><p>(You can see more stuff if you actually hit the URL but the idea is the same)</p><p>Secondly, you need to add domains to your entitlements:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*NFhvhIr65qd5g_LV" /></figure><p>And thirdly, you need to write some code which basically verifies that the ActivityType is BrowsingWeb and that there is a URL.</p><pre>func application(_ application: UIApplication,             <br>         continue userActivity: NSUserActivity,                      <br>            restorationHandler: <a href="http://twitter.com/escaping">@escaping</a> ([Any]?) -&gt; Void) -&gt; Bool {<br>    <br>    guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,<br>    let url = userActivity.webpageURL else {<br>      return false<br>    }<br>    …<br>}</pre><p>We did this and tested a little bit. Everything worked fine, and we went off to argue about what the links should look like going forward.</p><p>Here’s what the argument was about. We had our initial approach that I described, which worked using page id. Typically (e. g. by AppsFlyer and branch.io) a different approach is used. Usually, it works like this. You don’t have a concrete screen identifier, but rather just some sort of ref for the link. When the app launches, it sends the ref to the server, obtains an answer as to where to land and lands there.</p><p>https://m.badoo.com/aa/landto/?page=9&amp;user_id=1234567<br>vs<br>https://m.badoo.com/aa/landto/?ref=abcdef</p><p>The problem with the second option is that, while the application is obtaining content, we’d want to display some sort of a skeleton preview before the whole page is loaded, and the second approach doesn’t allow us to do so (in particular, AppsFlyer doesn’t allow you to do so at all).</p><p>What did we decide to go for? Both. We just used both approaches and got something like this:</p><p>https://m.badoo.com/aa/landto/?ref=abcdef&amp;page=9&amp;user_id=1234567</p><p>Basically, this is a decent solution: we can use ref both for statistics and for controlling extra server behaviour, depending on what kind of link it was (for example, we have links which give credits). At the same time page id and user id can be used to launch, immediately show skeleton of the user’s profile page and happily perform ‘get user’. In a parallel request the ref is reported to the server.</p><p>However, another problem arose. Managers came to us and said, “Guys, we have a really long link. How are people going to deal with it?”</p><p>Once again, the solution is quite clear and has been on the web for a really long time. It’s link minifiers!</p><h3>How we minified universal links</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*eTUhJW8otf-we8x8" /></figure><p>Basically, we retain all the properties in a short link. There will be a page identifier, and a content identifier — so it can be done.</p><p>Then we remembered that redirects don’t work with universal links and got sad. What do we do?</p><p>After some experimentation, it turned out that you can actually redirect, but to do so you need a little hack. It’s pretty simple. Your minifier (it has to be your own minifier on a separate domain) is also registered as a deep link domain in the app, with its own apple-app-site-association for it. Then you write code for it, and, correspondingly, both domains are deep links.</p><p>This way both https://bdo.to/u/abcdef and https://m.badoo.com/aa/landto/?ref=abcdef&amp;page=9&amp;user_id=1234567 are registered as a universal link in the app.</p><p>Moreover, it is quite easy to implement. Quite simply, the app, when opened from a minifier, performs an http request, gets a URL to redirect to and uses that link with the existing logic for long links.</p><h3>How deferred deep links work</h3><p>You might remember that I started the AppsFlyer story with how accessing the content in the deep link worked if you need to install the app first. That’s called deferred deep linking (because you defer the landing until after the app is installed).</p><p>This is the only bit which we didn’t do ourselves and still used AppsFlyer to help us with this. In principle, you could do it yourselves — we just didn’t want or need to.</p><p>What is the idea behind it? The user opens an AppsFlyer http link, the user is fingerprinted with everything you can grab from Safari (i.e. IP address, iPhone model, clock delay etc.), and redirected to the App Store. The user installs the app and launches it. After that, the AppsFlyer SDK reports the same data (IP address, phone model etc.) to their server. The server then correlates whatever they got from the SDK with people who recently followed links associated with this app and draws the conclusion as to which link needs to be opened.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l38U9dQN4kvCFWh2" /></figure><p>Here’s how it all works together. The minifier redirects to our link. If the app is not opened by this point, it means that the app is not installed, and so it’s reasonable to redirect to AppsFlyer. AppsFlyer redirects to the App Store with tracking and does what it needs to do as described above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z4wEAGs3WKXmLBct" /></figure><h3>How nothing works in SafariViewController</h3><p>While we were busy doing all this stuff, someone from QA came to us and said, “Guys, I am sending a link to myself via Telegram, Skype and HipChat and nothing is working when I tap on them” And we answer, “Hang on, it’s working on our machines.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*mFsQX7wCQZzDkSv0" /></figure><p>It turned out the problem was related to SafariViewController.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*uNA_MiN42DeUe-l4" /></figure><p>The story with SafariViewController is totally tragic. Here’s the deal. Apple’s idea was that if a user opens Safari, enters a universal link and presses Enter, it will not open an application. That makes sense; if you are a user, you do not expect, when you press Enter in the browser, that you will suddenly be thrown into a different app.</p><p>It’s the second bit which doesn’t make sense. When the application opens SafariViewController, exactly the same thing happens, as if the user had entered the link into the window and had pressed Enter. There is no way to open a universal link when the app uses SafariViewController.</p><p>So, we add to our list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y1lr_E527kdN6vVv" /></figure><p>If the user entered the link into Safari themselves or opened SafariViewController — nothing works. You are forced to display a web page or redirect to App Store. We thought about this for a while and then came up with a solution.</p><p>Here’s our idea: since we’re forced to open a web page, we will open the web page. Universal links do work when opened <strong>from</strong> SafariViewController, so we’ll just have a button that link to the very same page. In principle, that should trigger the universal link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*OHQm7IEiIULIPACi" /></figure><p>Except of course it didn’t.</p><p>That didn’t take too long to figure out, and here’s a new entry to our list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PltEXNYGrubERRaJ" /></figure><p>If the user clicked on a link in the same domain in which they are currently located, it does not open the application.</p><p>What can we do? What else can we do? <br>It’s going to be another hack, of course.</p><p>It is all quite simple: we create two domains and register them both as a universal link. This is what it looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*l7TMKbTGDAPaRjvb" /></figure><p>The user opens m.badoo.com, but the link on the button will lead you to mlink.badoo.com. You can even copy this link and send it; it works both ways. Both these domains work for us as equivalents. Correspondingly, if a user opens mlink.badoo.com, the link on the button will be to m.badoo.com.</p><p>And that finally worked!</p><h3>What the system looks like with web preview</h3><p>In general terms things have got even better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z9wn61KpVI0JS79D" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oafuf5xcWyK_2vka" /></figure><p>Now, the minifier redirects to the full link. The full link on m.badoo.com shows a preview which directs to mlink.badoo.com via the button. The alternative link on mlink.badoo.com redirects to AppsFlyer, and from there the user is redirected to the App Store with tracking.</p><p>Despite the complexity, things were starting to work somewhat better. At least people were more or less able to open content in Safari and Telegram.</p><h3>How we encountered mysterious bugs and solved them</h3><p>That’s when our good old QA person came to us again with a very sad face and said, “You know what, you have got some very strange things happening.”</p><p>(Cue mysterious music here)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*pBLkGQsZb_tXw4QT" /></figure><p>On some devices (only on some) for some reason, universal links in our app did not work. At all. Other apps worked perfectly fine.</p><p>We worked out why. When following a universal link and launching an app, the following button appeared in the top right-hand corner of the screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*uiXN-rQjPRYiw04C" /></figure><p>And this button does two things. Firstly, it opens Safari. Secondly, it ‘breaks’ deep links once and for all for your application!</p><p>And now the only way to ‘unbreak’ the deep links is to long-tap the link, to click ‘open in Badoo’, and then everything will work fine again. But, as far as I can remember, not a single end user ever did that. They just lived without deep links for the app from that point onwards. And there’s nothing you, as a developer, can do. The only point for you is: don’t touch this button yourself.</p><p>Fortunately, in its infinite wisdom last autumn, Apple gave us a fantastic present and removed this button from iOS 11.</p><p>However, if you support iOS 9 and 10, remember about this button. And, if you happen to support iOS 9, remember that apple-app-site-association should not be disallowed to robots in robots.txt. That’s another mysterious bug we’ve spent way too much time on. Here’s the full list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-PFy2_gKJd3agVLH" /></figure><h3>How to version deep links</h3><p>We had already made a lot of painful mistakes. And then a new feature made us make a few more.</p><p>Badoo decided to create a new, cool function called ‘Lookalikes’.</p><p>The idea was very simple. You take someone’s photo with your phone’s camera or use an existing photo and we will find people on our service who look like that person. You can search for celebrities, friends or even for yourself, looking for your own doppelgangers. Great idea, good for marketing.</p><p>It was so great that our managers said that we had to change our approach for that feature specifically. The existing one looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hN16Tu57EMn1bJiY" /></figure><p>We were really keen that, when our users share lookalikes with one another, the recipients can see them. Whatever happens, nothing should stand in the way of that. So, if the given app is not installed, we no longer send them to the App Store; we simply open the content on mobile web. The new approach looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FB4d_51nk3ch2V4F" /></figure><p>That didn’t seem like much at first. We say, “Right, if the address has another page id, we will use that to redirect to mobile web.”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-QOF3uvwM5r9yg67" /></figure><p>This wasn’t complicated; we implemented and tested it in a couple of days. However, then we realised that this is a new functionality that we had never had in our apps before.</p><p>And that means that even if an app is installed, it still isn’t certain that we need to open it. Actually the approach should look more like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fA8sKOYqRba4Zxi_" /></figure><p>If an app is installed, you need to check whether it supports the new functionality. And only if it supports the new functionality, should you open the content in the app. Otherwise, you should direct to the mobile web.</p><p>By the time we released the feature, it was only available on the web, but we wanted to bring it to all platforms gradually. And that brings us to the subject of versioning the links. Particularly, versioning of minified links.</p><p>Once again, ideally everything is very simple. We have an old version and a new version. The idea is that the old version only opens /u paths, and the new version opens /u paths and, let’s say, /l/a paths from ‘lookalikes’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7YXFaZ-VU_4I7Zji" /></figure><p>We rolled up our sleeves and thought, “Right, let’s get this done.” But it turned out to be impossible to do it right.</p><p>Remember how at the beginning I told you about how to set up links? You might remember that the paths that are supported by the app are specified in the apple-app-site-association file. It turned out, that’s the only place where the paths are specified.</p><p>Consequently, as soon as we add a new path, it starts opening all versions of the app, including the old one which knows nothing about it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*dFQRVJO84hWa-4Y1" /></figure><p>In practice, the new link crashed our old app completely, because we forgot to take that into account. And there was nothing more we could do about that. The only thing that we did was to wait for the new app to accumulate a sufficient number of users and, only then, did we switch it on on the server side.</p><p>You however, can live a better, healthier life than me and think about all this in advance. When the app starts from a URL, check whether you can open such a URL and, where necessary, return a ‘false’ response:</p><pre>func application(_ application: UIApplication,             <br>         continue userActivity: NSUserActivity,                      <br>            restorationHandler: <a href="http://twitter.com/escaping">@escaping</a> ([Any]?) -&gt; Void) -&gt; Bool {<br>    <br>    <strong>guard</strong> userActivity.activityType == NSUserActivityTypeBrowsingWeb,<br>    let url = userActivity.webpageURL,<br>    <strong>canOpenUrl(url: url) else {<br>      return false</strong><br>    }<br>    …<br>}</pre><p>In this case, if a user’s outdated version of an app attempts to open something it doesn’t support, then Safari will open instead. And, as soon as the new version supports it, canOpenUrl of this version will return a ‘true’ response and the new version will open.</p><h3>How we tamed Facebook</h3><p>When everything became more or less stable, our marketing team wanted to advertise with universal links on Facebook. Go ahead, I told them, it should work everywhere.</p><p>Not so fast.</p><p>It turned out that Facebook doesn’t care one bit about new technologies and advancements in universal linking. They still live in the age where deep links look like the original badoo://user/1234567 and actually require the link in that format from advertisers. The only alternative is their weird proprietary standard.</p><p>It’s called <a href="https://developers.facebook.com/docs/applinks/">Facebook App Links</a>. It’s pretty much a continuation of the OpenGraph idea: you add some meta tags to your html for Facebook. They look like this:</p><pre>&lt;meta property=&quot;al:ios:url&quot; content=&quot;<strong>badoo://landto/?page=138&amp;ref=39ynkri</strong>&quot;&gt;<br>&lt;meta property=&quot;al:android:url&quot; content=&quot;<strong>badoo://landto/?page=138&amp;ref=39ynkri</strong>&quot;&gt;</pre><pre>&lt;meta property=&quot;al:ios:app_store_id&quot; content=&quot;351331194&quot;&gt;<br>&lt;meta property=&quot;al:ios:app_name&quot; content=&quot;Badoo - Meet New People, Chat, Socialize&quot;&gt;<br>&lt;meta property=&quot;al:android:package&quot; content=&quot;com.badoo.mobile&quot;&gt;<br>&lt;meta property=&quot;al:android:app_name&quot; content=&quot;Badoo - Meet New People, Chat, Socialize&quot;&gt;</pre><p>You’ll need to serve those tags with your html or at least to the facebookexternalhit/ User Agent.</p><p>The links in the meta tags still need to be in badoo://something format. So as you see, we decided we would just reuse our typical scheme here.</p><p>Note that this approach only works if you are buying ads from Facebook with this link. If the link is shared in Facebook by your own users, it will still open the in-app browser. The html preview we used to fight against SafariViewController is still your friend here.</p><h3>When we still use old-style links</h3><p>Do you remember how earlier, starting with iOS 9, we got a Safari error, if a given user had not installed an app? That doesn’t look good; we don’t want users to see error messages. And do you remember this email?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*911hSlbtBQF1AgkA" /></figure><p>Buttons in this kind of emails will log the user in (using a temporary token), and redirect them to the particular “like”.</p><p>So these messages are individualised for specific users. And we actually keep the stats for each one of our users: which version of an app are they using and on which device. That means that for this kind of email specifically, we can sometimes use the old approach.</p><p>Here’s how it works. We know that Ben has our app installed on his iPhone X with iOS 11.1 and logs in regularly, the last time being 4 hours ago. If he opens the email from an iPhone X with iOS 11.1, we simply redirect him to badoo://landto/&lt;link&gt;<strong>. </strong>The probability that he will see an error is very low. The only case in which that might happen is if he’s just deleted the app.</p><p>The upside of that risky approach is that it completely bypasses all SafariViewControllers and similar. Gmail app on iOS notoriously uses one, so using that approach is a big win for its users.</p><h3>How to do universal links, tl;dr</h3><p>I’ve told you our story in so many kilobytes, now let me give you a shorter takeaway on how to implement great universal links without outsourcing it to someone.</p><p>By the way, when I say “outsourcing to someone”, in my opinion that specifically means branch.io. To the best of my knowledge they are the only company that actually know how deep links work — and that includes Google’s Firebase to my great surprise. I can’t fully recommend one of these vendors because I’ve never worked with either of them, but I’ve tested their solutions extensively in various apps, and that’s my honest opinion as a fellow implementer.</p><p>So, anyway, you’ve decided to not use branch.io. Here’s what you have to do:</p><ol><li>Think up a URL scheme for your universal links. It should be a separate path specifically reserved for deep links and include parameters with some kind of screen id, data id and ref for stats and tracking. E. g. <a href="https://m.badoo.com/aa/landto/?ref=abcdef&amp;page=9&amp;user_id=1234567.">https://m.badoo.com/aa/landto/?</a><a href="https://m.badoo.com/aa/landto/?ref=abcdef&amp;page=9&amp;user_id=1234567."><strong>ref=abcdef&amp;page=9&amp;user_id=1234567.</strong></a></li><li>Get an alternative domain with the same URL structure that will just redirect back to the original domain, whatever the address is. E. g. <br>https://mlink.badoo.com/anything → <a href="https://m.badoo.com/anything">https://m.badoo.com/anything</a></li><li>Think up a “native” scheme such as badoo://landto/?ref=abcdef&amp;page=9&amp;user_id=1234567. You can use the same parameters as with the URL scheme.</li><li>If you want a URL minifier, get your own domain for that.</li><li>Do what <a href="https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html">Apple tell you in in their instructions</a> and what <a href="https://developer.android.com/training/app-links/deep-linking">Google tells you in theirs</a> for setting up your domains. When writing the code, don’t forget to check whether the URL you received is actually openable by the app and fall back to browser otherwise. Set up the “native” scheme links as well.</li><li>On your main domain address start serving html preview. This html preview will have:<br><strong>a.</strong> Some preview of the linked content<br><strong>b.</strong> A button leading to the same URL on an alternative domain<br><strong>c. </strong><a href="http://ogp.me/">Opengraph</a> tags with image and header and <a href="https://developers.facebook.com/docs/applinks/">app links</a><br><strong>d.</strong> A logic that redirects the user to the app store when redirected from alternative domain</li><li>If you want, instead of redirecting to the app store you can redirect to a fingerprinting/installation tracking service, such as AppsFlyer or something you’ve built yourself. See <a href="https://docs.google.com/document/d/1ScTJBf-JgBok_iVyo3xxQdZ_okl9fr_3kaqfTLMHIHs/edit?disco=AAAACDQMWOk&amp;ts=5b7d880a#heading=h.kucx63wrp88f">How deferred deep links work</a>.</li></ol><p>That’s it. Good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ddb1e70cab0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bumble-tech/universal-links-for-android-and-ios-1ddb1e70cab0">Universal links for Android and iOS</a> was originally published in <a href="https://medium.com/bumble-tech">Bumble Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>