2

I have to open my iOS app whenever user open a link of my app in browser. I have already used a like myApp:// but i want to open my app even when user open an http link a from browser. Just like pinterest. Pinterest opens app even if i open a regular http link like this http://www.pinterest.com/pseudoamber/ and using URL scheme as well like this pinterest://www.pinterest.com/pseudoamber/. My app is opening on myApp://www.myapp.com now i want to open my app when user open an http link like this http://www.myapp.com

Anybody please help

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Mashhadi
  • 3,004
  • 3
  • 46
  • 80

1 Answers1

4

Here is an example using jQuery:

$(document).ready(function() {

        var user_agent_header = navigator.userAgent;

        if(user_agent_header.indexOf('iPhone')!=-1 || user_agent_header.indexOf('iPod')!=-1 || user_agent_header.indexOf('iPad')!=-1){
            setTimeout(function() { window.location="myApp://www.myapp.com";}, 25);
        }

    });
Piotr Tomasik
  • 9,074
  • 4
  • 44
  • 57
  • Thanks for reply but the thing is that i have to open my app even if user write www.myapp.com in browser. for this purpose i'll have to add "http" URL scheme and a host name but i don't know how to do this – Mashhadi Apr 15 '14 at 10:38
  • You simply put the above javascript at the website @ www.myapp.com – Piotr Tomasik Apr 15 '14 at 10:44
  • it will redirect to mypp:// but if user do not have app in his iPhone then it will generate an error i think. Then what we should do – Mashhadi Apr 15 '14 at 16:00
  • what is "myApp://www.myapp.com" ? What should I give for my app ? What will happen if my app is not installed in the phone and still the user tries to call for my app ? – user2955351 Oct 20 '14 at 10:17