Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In iOS, I want to open my app from a link which is coming in mail

Tags:

ios

iphone

In iOS, I want to open my app from a link which is coming in mail. Link format is http://test.com on click of link if app is installed then it open the app else open the web browser. Some one please help me.

like image 730
MaC Avatar asked Sep 09 '16 07:09

MaC


2 Answers

Universal links are supported since iOS9 and these are likely what you are searching for.

When you support universal links, iOS 9 users can tap a link to your website and get seamlessly redirected to your installed app without going through Safari. If your app isn’t installed, tapping a link to your website opens your website in Safari.

like image 191
tilo Avatar answered Nov 08 '22 08:11

tilo


For iOS9 or newer, look at tilo's answer (Universal Links).

For iOS8 or older, it is more cumbersome Adding an URL Scheme to your application. This is done by doing the following steps:

  1. Open Xcode
  2. Open the project
  3. Click on the project file to the left
  4. Choose your target of your app
  5. Click on the "Info" tab.
  6. Go all the way down and expand the "URL Types"
  7. add a urltype forexample "MyAwesomeApp".

Your app will now open any links that begin with "MyAwesomeApp://" Try it out in safari, type "MyAwesomeApp://test". If your app is installed on the device it will open.

The custom URL Scheme will only work on devices that has your app installed. To fix the case where the user does not have your app installed, you have to link from the email to a webpage that tries to open your app but has a http URL as a fallback:

window.location = 'MyAwesomeApp://';
setTimeout(function() {               
   window.location = "http://urlToMyAweSomeAppHomePage.com";
}, 1000);
like image 21
Peep Avatar answered Nov 08 '22 08:11

Peep