Haring icon indicating copy to clipboard operation
Haring copied to clipboard

Can't get email link to work

Open stefandesu opened this issue 8 years ago • 3 comments

Hi,

First of all, thanks for keeping MarkdownKit alive with this project. I'm almost finished making my first app and I'm using Haring for the About section.

Unfortunately, I haven't been able to get email links to work. Neither [Mail]([email protected]) nor [Mail](mailto:[email protected]) nor [Mail](message://[email protected]) are working. Just writing the email address still converts it to a link, but tapping it still doesn't do anything. A long press opens the Open/Copy/Share menu, but even then "Open" doesn't do anything.

Am I doing something wrong or is this a bug?

Thanks!

stefandesu avatar Dec 13 '17 20:12 stefandesu

I just modified the example and used Email [User at example dot com](mailto:[email protected]) and it seems to work. Using Xcode 9.2, iOS 11 SDK, running on iOS 11.2 physical device and it works in my testing. Are you using a device or the simulator?

DavidLari avatar Dec 14 '17 00:12 DavidLari

Found the mistake! What I actually did was [[email protected]](mailto:[email protected]) which apparently doesn't work. To get down to the issue, I added the textview delegate like in your examples, and found out that the URL it tries to open is not "mailto:[email protected]" but rather "[email protected]" which does not work. I discovered by accident that it actually takes the content of the square brackets as the URL. I think it might be the automatic detection working against the manual link syntax. In fact, when I disable automatic link detection, [[email protected]](mailto:[email protected]) works properly.

I also found out that if I implement the delegate like in your example, i.e. using UIApplication.shared.open AND return true, it opens the mailto link both in Mail.app and in a new email window inside the app. To fix it, I changed it to return false. Do you think this might have any disadvantages?

Thanks for helping me with the issue. We might have discovered a small bug as well.

stefandesu avatar Dec 14 '17 08:12 stefandesu

I will take a look and see if I can understand better what the code is doing. Since I didn't write this I'm not very familiar with how it works.

DavidLari avatar Dec 14 '17 13:12 DavidLari