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.
Exactly what I was looking for! Thanks for the post.
I’m trying the solution but it is not working…
It keep saying: Failed to load webpage with error: The URL can’t be shown
Any suggestions ? I’m using phonegape 3.0
Thank you, saved me a heap of trouble!
Finally! I’ve been trying to fix this for several hours but was making far too narrow searches. I was either getting the mailto enacted but an error page in a new webview (calling open with _blank), or net::ERR_UNKNOWN_URL_SCHEME using _self or no target argument.
This didn’t work for me on ios7 and cordova 3.5. But the following did:
based on the basic mailto link idea which is :
hope it helps.
This doesn’t work for me also (cordova 3.6.3, Android 4.12).
Tried also on tap (jquery)
and location.replace
Nothing works !
This works in few models of Android. In some it didn’t. I explored further and found this.. https://github.com/siegfriedbolz/cordova-plugin-email-composer/tree/9cb1cfb#examples
Cheers
window.location.href opens the link in a full screen browser. How can I have a Done button which we get in inappbrowser included in this approach?
Try using:
window.open(“mailto:?subject=Something to share with you…”,’_system’);
Thanks, @Vishwani. I was almost giving it up for today, but by looking at your last coment I saw I was missing the second argument, ‘_system’. After putting it iOS finally opened the default email app.
For those which solution is not working, maybe you need to add to your config.xml the following line:
Hope it helps!