2

The main task I'm trying to achieve is to open my app with a URL.

Adding the custom URL scheme to the appName-Info.plist everything works fine using the corresponding handleOpenUrl: etc etc.

My point is that my app has got a webSite as well. So what I'm trying to do is, given an url to my users (tiny, short url doesn't matter) combine together these 3 different cases:

  • If the user opens the URL from his iPhone and he's got the app installed: open the iPhone app;
  • If the user opens the URL from his iPhone and he hasn't got the app installed: open the iTunes store URL of the app;
  • If the user open the the URL from his phone (android, tablet, etc) , or from the web, show the web page instead.

My problem is that I can achieve all these tasks separately but I cannot combine all together.

Note: tried to add the http://myApp.com to the UrlScheme but of course didn't work coz the http:// is managed by Safari in the iPhone.

Any idea? Help and suggestions would be really appreciated. Tks a lot chaps.

DennyLou
  • 96
  • 2
  • 9
  • 1
    Take a look here: http://stackoverflow.com/questions/1108693/is-it-possible-to-register-a-httpdomain-based-url-scheme-for-iphone-apps-like/1109200#1109200 I think this is (unfortunately) still the best solution. – Steven Fisher Jun 06 '12 at 01:48
  • Steven beat me to it, I suggest checking that link out as well – skram Jun 06 '12 at 01:50

2 Answers2

3

This SO question seems to have the answer you're looking for:

  1. Check if the user-agent is that of an iPhone/iPod Touch
  2. Check for an appInstalled cookie
  3. If the cookie exists and is set to true, set window.location to your-uri:// (or do the redirect server side)
  4. If the cookie doesn't exist, open a "Did you know Your Site Name has an iPhone application?" modal with a "Yep, I've already got it", "Nope, but I'd love to try it", and "Leave me alone" button.

The "Yep" button sets the cookie to true and redirects to your-uri:// The "Nope" button redirects to "http://itunes.com/apps/yourappname" which will open the App Store on the device The "Leave me alone" button sets the cookie to false and closes the modal The other option I've played with but found a little clunky was to do the following in Javascript:

Community
  • 1
  • 1
Jason Kulatunga
  • 5,814
  • 1
  • 26
  • 50
1

This would solve one of your problems, it will link the user to the app page:

itms-apps://itunes.com/apps/APPNAME
Neil
  • 2,004
  • 3
  • 23
  • 48