Arpith Siromoney 💬

From Website to App

Opening your web content in your app

You’ve built a website, and want to take a user to your app if they’ve installed it. Basically, you want universal links but want to support iOS 7 and 8 as well. 

This is how I did it in Constellational, the app I’m building to share notes.

<script type='text/javascript'>
 var url = window.location.href;
 if (url.substring(0,7) === 'http://') {
   url = url.substring(7);
 } else if (url.substring(0,8) === 'https://') {
   url = url.substring(8);
 window.location.href = 'constellational://' + url;

That code checks if the url of the page that the user is on looks like or, and replaces the protocol with my custom url scheme, constellational://

Have a better way to do this? Let me know!

Want to share notes? Sign up here!