We are updating a Phonegap application we wrote last year this week.  Originally the application was developed against Phonegap version 2.1.  Back then we used ChildBrowser plugin to get the in-application browser working. Since then they have moved that functionality into the core.  But as we migrated our application forward we found we had an issue that we just couldn’t seem to get around.

In our application users can share an article via email.  We didn’t need to do that in app so we skipped the plugin route and just stuck with the mailto: protocol in a link.  This worked great in our 2.1 version of the app. However after migrating forward to 3.0 we were having issues with the system telling us we were using an unsupported protocol.  We thought the issue was in regards to the InAppBrowser migration but it turns out it was not.

We trigger our mailto from a button not a link (href) so we were using javascript.  Our original code that worked fine in Phonegap 2.1 looked like:

window.open("mailto:?subject=Something to share with you...");

But the solution we found for making mailto work in Phonegap 2.9/3.0 was:

window.location.href = "mailto:?subject=Something to share with you...";

In case you find yourself wanting to use the mailto and running into issues I hope you find this useful.

Share This