Ben Packard
Ben Packard

Reputation: 26476

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?

Upvotes: 9

Views: 5500

Answers (1)

AndyDunn
AndyDunn

Reputation: 1084

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.

Upvotes: 8

Related Questions