‹ BackHN Continuity

Thread

QR codes that route to the appropriate app store

20 points · 11 comments · matthuggins

  1. elendilm · · focus · HN ↗
    For our apps Slyp and SlypBusiness, we had the same QR code for each app open Playstore/Appstore page of the app depending on the phone. Hopefully, we will start rolling out Slyp next week.

    Just have a branded link (like <a href="https:&#x2F;&#x2F;slyp.app&#x2F;Slyp" rel="nofollow">https:&#x2F;&#x2F;slyp.app&#x2F;Slyp or <a href="https:&#x2F;&#x2F;slyp.app&#x2F;SlypBusiness" rel="nofollow">https:&#x2F;&#x2F;slyp.app&#x2F;SlypBusiness) to the official web page and have the js in that page auto-redirect and open the original Playstore&#x2F;Appstore page.

    And yes, we used userAgent for identifying the platform.

    If anyone is interested, here is the code. May not cover all edge cases but works for our usecase. The code was wrung together in a hurry a year ago.

        window.addEventListener(&#x27;DOMContentLoaded&#x27;, (event) =&gt; {
            let app = &#x27;Slyp&#x27;
    
            var userAgent = navigator.userAgent.toLowerCase();
            if (userAgent.indexOf(&#x27;android&#x27;) &gt; -1) {
              window.location.href = `https:&#x2F;&#x2F;play.google.com&#x2F;store&#x2F;apps&#x2F;details?id=com.ndcurve.${app}`;
            } else if (userAgent.indexOf(&#x27;iphone&#x27;) &gt; -1 || userAgent.indexOf(&#x27;ipod&#x27;) &gt; -1 || userAgent.indexOf(&#x27;ipad&#x27;) &gt; -1 || userAgent.indexOf(&#x27;mac&#x27;) &gt; -1) {
                  if (app === &quot;Slyp&quot;)
                    window.location.href = &#x27;https:&#x2F;&#x2F;apps.apple.com&#x2F;app&#x2F;&lt;app_id&gt;&#x27;;
                  else if (app === &quot;SlypBusiness&quot;)
                    window.location.href = &#x27;https:&#x2F;&#x2F;apps.apple.com&#x2F;app&#x2F;&lt;app_id&gt;&#x27;;
                  else
                    window.location.href = &#x27;https:&#x2F;&#x2F;slyp.app&#x27;;
            } else {
              window.location.href = `https:&#x2F;&#x2F;play.google.com&#x2F;store&#x2F;apps&#x2F;details?id=com.ndcurve.${app}`;
            }
        });
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.