0

Before I ask my question I know how to register url schema. This suggests the same. But this holds true if we have a custom url schema. What if we have to open a url with https schema. Not all https links. Ones only of my application. e.g. https://www.myurl.com or https://www.myurl.com/groups. I want that wherever I find these link on iPhone (email, SMS, Safari), my app should be opened.

Community
  • 1
  • 1
Nitish
  • 13,845
  • 28
  • 135
  • 263
  • You can do javascript redirection in https schema.. – iphonic Mar 09 '15 at 06:05
  • 1
    you mean launching your app from your website ? if yes try [this](http://stackoverflow.com/questions/6964515/launching-app-or-app-store-from-safari) – Huy Nghia Mar 09 '15 at 06:06
  • I meant exactly same as @HuyNghia. This is the way. – iphonic Mar 09 '15 at 06:06
  • @HuyNghia : Where shall this javascript function go ? I know somewhere on server, but where ? And do I need to do anything except for implementing AppDelegate handleOpenURL ? – Nitish Mar 09 '15 at 06:08
  • @Nitish It should be in your html page pointed by the url you have, can be your index.html. on the url https://www.myurl.com – iphonic Mar 09 '15 at 06:10
  • as @iphonic said, you could put "onload" event instead "onclick" – Huy Nghia Mar 09 '15 at 06:12
  • 1
    suggest for you to check when user didn't install your app , will open your app link http://stackoverflow.com/questions/13044805/how-to-check-if-an-app-is-installed-from-a-web-page-on-an-iphone – Huy Nghia Mar 09 '15 at 06:18
  • @HuyNghia : Thanku for your solution. I have work with server team for fixing this then. I will confirm this after they make the change. – Nitish Mar 09 '15 at 06:26
  • 1
    glad it help I think the [second link](http://stackoverflow.com/questions/1108693/is-it-possible-to-register-a-httpdomain-based-url-scheme-for-iphone-apps-like/1109200#1109200) is right solution for you. check it first :) – Huy Nghia Mar 09 '15 at 06:28

2 Answers2

1

You cannot control the https/https schema to redirect to an app as they are registered with browser.

So once User click on any http link it will launch the browser. Approach that is widely used is to redirect from the browser to the app if it is installed.

bllakjakk
  • 5,045
  • 1
  • 18
  • 28
  • Alright. And is that approach the same as HuyNghia has suggested in his comment ? – Nitish Mar 09 '15 at 06:12
  • Once on clicking the link, browser will be launched and by using the way as suggested by HuyNghia to check and launch the app. – bllakjakk Mar 09 '15 at 06:18
0

You should redirect to the register url schema on your https url, and you can check the browser who is using the url by js, than match the redirect, like this:

var isMobile = {
    Android: function() {
        return navigator.userAgent.match(/Android/i);
    },
    BlackBerry: function() {
        return navigator.userAgent.match(/BlackBerry/i);
    },
    iOS: function() {
        return navigator.userAgent.match(/iPhone|iPad|iPod/i);
    },
    Opera: function() {
        return navigator.userAgent.match(/Opera Mini/i);
    },
    Windows: function() {
        return navigator.userAgent.match(/IEMobile/i);
    },
    any: function() {
        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
    }
};

if ( isMobile.Android() ) {
    document.location.href = "y";
}
else if(isMobile.iOS())
{
    document.location.href="x";
} 

And this link should help you also.

Community
  • 1
  • 1
Wayn Liu
  • 394
  • 3
  • 13