Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to handle your own http URL schemes in iOS?

Tags:

ios

url-scheme

iTunes, App Store and YouTube on iOS clearly register http://... URL schemes to open their apps.

Can anyone do that, not just your own protocol?

The reason I want to do this is that I am working on an app for a festival. I want to "intercept" links to specific pages on the website and launch the app instead, if installed.

So far I have no had much luck

like image 436
baswell Avatar asked Dec 09 '10 23:12

baswell


People also ask

How do I get iOS URL scheme?

First, you have to download the IPA file for the app, which requires macOS and Apple Configurator 2. When you finally find the IPA, you have to turn it into a ZIP file, show the contents of the app package, then hunt for the specific PLIST file that contains the scheme names.

What is URL scheme in iOS?

URL schema is used as an identifier in launching applications and performing a set of commands in iOS devices. The schema name of a URL is the first part of a URL. (e.g. schemaname:// ). For web pages, the schemas are usually http or https.


3 Answers

The way you can do this for "http://" URLs (and what I think Apple and Spotify do) this is to:

  1. Register a custom URL scheme like the other answers have shown.

  2. Set up your HTTP URL to point to a real webpage.

  3. Put a script on that page to redirect to your custom URL if is on iOS.

For example, here is a sample page which will take you to the Twitter app for a particular user or the Twitter website depending upon if you are on the web or on your iOS device:

<!DOCTYPE html> <html> <head>     <meta charset="utf-8">     <title>Twitter</title> </head> <body>     <script type="text/javascript">         var username = document.location.search.substr(1);         document.location.replace(             "standalone" in window.navigator ?             'twitter:@'+username :              // iOS             'http://twitter.com/'+username);    // others     </script> </body> </html> 

Try it out here: http://bl.ocks.org/d/3153819/?mckamey

like image 101
mckamey Avatar answered Oct 03 '22 14:10

mckamey


iOS 9 supports Universal Links, which allows iOS to launch an app based on a standard http:// URL (based on the hostname) without the user having to go through Safari.

It requires some web server configuration (you need a website), but once setup, the registered app will open the link instead of Safari.

For the users that don't have iOS 9, you can use Smart Banners to ease the experience.

like image 41
Marcus Adams Avatar answered Oct 03 '22 12:10

Marcus Adams


Unfortunately I don't think you can do that. You can register your own custom scheme e.g yourFestival:// and pass data from the outside world (SMS , email , other apps) to your app.

I wrote a blog post about this here : Using custom schemes and passing data between iOS apps.

I hope this helps.

like image 44
Marius Ciocanel Avatar answered Oct 03 '22 12:10

Marius Ciocanel