¿Hay formas de crear un enlace que abra la aplicación si está instalada, o el sitio si no? [duplicar]

Posible duplicado:
iPhone Safari: ¿comprueba si el esquema de URL es compatible con 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?

preguntado el 09 de marzo de 12 a las 14:03

Vea stackoverflow.com/questions/627916/…. I'll flag this as duplicate. -

1 Respuestas

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 al webView objeto.

¡Buena suerte!

respondido 09 mar '12, 15:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.