PhoneGap Email Composer Plugin
I've built a simple jQuery Mobile based app, and trying to compile it with Phonegap. I'd like the users to be able to send some content from the app via email, but I can't figure this out.
My code:
<script type="text/javascript" src="json2.js"></script>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" src="EmailComposer.js"></script>
<script src="js/jquery-1.5.min.js"></script>
<script src="js/jquery.mobile-1.0a3.min.js"></script>
<script src="js/jsStuff.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// PhoneGap is ready
//
function onDeviceReady() {
// Empty
}
// alert dialog dismissed
function alertDismissed() {
// do something
}
// Show a custom alert
//
function doEmail() {
window.plugins.emailComposer.showEmailComposer("Subject","PlainTextBody", "recipient,recipient", "ccRecipient", "bccRecipient",false);
}
</script>
<link rel="stylesheet" href="style.css" />
And then:
<body onload="onLoad()">
<a href="#" onclick="doEmail(); return false;">Send email</a>
This does nothing at all.
What I've done:
- Downloaded the
EmailComposer
plugin. - Move
EmailComposer.js
to the root of my app (Phonegap project -> www). - Added
EmailComposer.h
&EmailComposer.m
to my project by right-clicking my www folder in Xcode, then "Add" --> "Existing Files..." (REference type: Default, "copy items into destination..." is checked) - Added
MessageUI.framework
to my project by rig开发者_JAVA百科ht clicking my project's target -> "Get info" and adding it to linked libraries.
Any help would be appreciated.
Okay, I know this is an old thread but it looks like the correct answer has not been posted. For future readers who may stumble on this:
You have to add the EmailComposer plugin into your PhoneGap.plist file, under plugins add a new row with "EmailComposer" in the left column, and "EmailComposer" in the right column.
You must add the plugin into the PhoneGap.plist.
Add a new entry with Key "EmailComposer" and value "EmailComposer"
As naugtur suggested, try some troubleshooting techniques, like.. does it work if you remove temporarily those custom scripts: jsStuff.js and json2.js? I know they may be required in your app but it may help you locate the source of the problem. Try sending console messages or alerts inside you doEmail function. Hope it helps.
Seems like the problem was related to the way I added the plugin files to the xCode project. If you need extra details: http://groups.google.com/group/phonegap/browse_thread/thread/6fd7d73d3532effd/4ae9daa0b746ceb5#4ae9daa0b746ceb5
Add to PhoneGap.plist Plugins: key 'com.phonegap.emailComposer' value 'EmailComposer'.
For those finding this question whilst trying to get an Email Composer to work, you no longer need to add things to the plist. The new CLI interface handles that for you.
The most current version of the Email Composer plugin is here - https://github.com/katzer/cordova-plugin-email-composer
And the way to add it to your project is this in the command line: cordova plugin add de.appplant.cordova.plugin.email-composer && cordova prepare
I think you have to change it to <a href="javascript:doEmail()">Send Mail</a>
, onclick isn´t a iphone event
精彩评论