Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening a custom url link in Safari/GMail

I am sending a custom url scheme link inside an email:

[body appendString:@"<div><a href=\"my-custom-url-scheme:test\"><button type=\"button\">Open in App</button></a></div>"];

This successfully adds a button in the email I am sending which, when tapped, opens my app (if it is installed).

This works fine when I open the email in mail.app on the iOS device, but doesn't do anything when I open the mail in Gmail (both via Safari and the native GMail app).

Is this a limitation of the framework? Or should safari be able to recognize these links?

like image 271
Ben Packard Avatar asked Jan 01 '13 17:01

Ben Packard


1 Answers

The best solution I've found for this is to link to a PHP script on a web server that takes parameters and redirects the request to your custom URL scheme within Safari.

This link will be in the email:

http://myserver.com/_script.php?parameter=one

This then redirects to:

myappscheme://open/?parameter=one

It does mean you have to open Safari to process the link, but given that you're opening the link from the GMail app anyway, I think thats a minor issue to get this working correctly.

like image 180
AndyDunn Avatar answered Oct 30 '22 20:10

AndyDunn