1

Possible Duplicate:
iPhone Safari: check if URL scheme is supported in javascript?

For example, my application is "exapp" and I want to make link on web-site that can open my application if it is installed.

If header HTTT_USER_AGENT contents iPhone. I write <a href="exapp://params">exapp</a>

if not I write: <a href="exapp.php">exapp</a>

So, when I open this link on phone I have exapp launched. But on other device I just have web-site.

I have the following problem: If application exapp isn't inslatted on my phone, i have an error: Safari cannot open this page...

Is there ways, to resolve this problem?

Community
  • 1
  • 1
Max
  • 2,293
  • 5
  • 32
  • 48
  • 1
    See http://stackoverflow.com/questions/627916/iphone-safari-check-if-url-scheme-is-supported-in-javascript. I'll flag this as duplicate. – calimarkus Mar 09 '12 at 15:03

1 Answers1

1

The problem is that the response from the browser is successful, so you do not have an exception condition to catch. Why not attempt to open the page and parse the resulting HTML. If you see the safari error response is there. If it is, redirect to your web page, if not, continue on.

You can get the full HTML from a link invocation as a string and parse it, check out stringByEvaluatingJavaScriptFromString on the webView object.

Good Luck!

MystikSpiral
  • 5,018
  • 27
  • 22