Skip to content

Commit

Permalink
Email Composer iOS 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RandyMcMillan committed Apr 13, 2012
1 parent 148947c commit a9a4d05
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 18 deletions.
38 changes: 22 additions & 16 deletions iOS/EmailComposer/EmailComposer.js
Expand Up @@ -5,11 +5,11 @@ function EmailComposer() {
}

EmailComposer.ComposeResultType = {
Cancelled:0,
Saved:1,
Sent:2,
Failed:3,
NotSent:4
Cancelled:0,
Saved:1,
Sent:2,
Failed:3,
NotSent:4
}


Expand All @@ -30,14 +30,14 @@ EmailComposer.prototype.showEmailComposer = function(subject,body,toRecipients,c
args.body = body;
if(bIsHTML)
args.bIsHTML = bIsHTML;

Cordova.exec(null, null, "org.apache.cordova.emailComposer", "showEmailComposer", [args]);
cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]);
}

// this will be forever known as the orch-func -jm
EmailComposer.prototype.showEmailComposerWithCB = function(cbFunction,subject,body,toRecipients,ccRecipients,bccRecipients,bIsHTML) {
this.resultCallback = cbFunction;
this.showEmailComposer.apply(this,[subject,body,toRecipients,ccRecipients,bccRecipients,bIsHTML]);
this.resultCallback = cbFunction;
this.showEmailComposer.apply(this,[subject,body,toRecipients,ccRecipients,bccRecipients,bIsHTML]);
}

EmailComposer.prototype._didFinishWithResult = function(res) {
Expand All @@ -46,10 +46,16 @@ EmailComposer.prototype._didFinishWithResult = function(res) {



Cordova.addConstructor(function() {
if(!window.plugins)
{
window.plugins = {};
}
window.plugins.emailComposer = new EmailComposer();
});
cordova.addConstructor(function() {
if(!window.plugins)
{
window.plugins = {};
}

// shim to work in 1.5 and 1.6
if (!window.Cordova) {
window.Cordova = cordova;
};

window.plugins.emailComposer = new EmailComposer();
});
72 changes: 72 additions & 0 deletions iOS/EmailComposer/index.html
@@ -0,0 +1,72 @@
<!DOCTYPE html>
<html>
<head>
<title></title>

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<meta charset="utf-8">


<!-- iPad/iPhone specific css below, add after your main css >
<link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="ipad.css" type="text/css" />
<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone.css" type="text/css" />
-->
<!-- If your application is targeting iOS BEFORE 4.0 you MUST put json2.js from http://www.JSON.org/json2.js into your www directory and include it here -->
<script type="text/javascript" charset="utf-8" src="cordova-1.6.0.js"></script>

<script type="text/javascript" charset="utf-8" src="EmailComposer.js"></script>
<script type="text/javascript">


// If you want to prevent dragging, uncomment this section
/*
function preventBehavior(e)
{
e.preventDefault();
};
document.addEventListener("touchmove", preventBehavior, false);
*/

/* If you are supporting your own protocol, the var invokeString will contain any arguments to the app launch.
see http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
for more details -jm */
/*
function handleOpenURL(url)
{
// TODO: do something with the url passed in.
}
*/

function onBodyLoad()
{
document.addEventListener("deviceready", onDeviceReady, false);
}

/* When this function is called, Cordova has been initialized and is ready to roll */
/* If you are supporting your own protocol, the var invokeString will contain any arguments to the app launch.
see http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
for more details -jm */
function onDeviceReady()
{
// do your thing!
navigator.notification.alert("Cordova is working")

var args;
cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]);



}

</script>
</head>
<body onload="onBodyLoad()">
<h1>Hey, it's Cordova!</h1>
<p>Don't know how to get started? Check out our <em><a target="_blank" href="http://docs.phonegap.com/en/edge/guide_getting-started_ios_index.md.html#Getting%20Started%20with%20iOS">Getting Started Guide</a></em>
<br />
<ol>
<li>Check your console log for any white-list rejection errors.</li>
<li>Add your allowed <strong>hosts</strong> in Cordova.plist/ExternalHosts (wildcards OK, don't enter the URL scheme)</li>
</ol>
</body>
</html>
4 changes: 2 additions & 2 deletions iOS/EmailComposer/readme.md
Expand Up @@ -6,10 +6,10 @@ Added Cordova 1.5 support March 2012 - @RandyMcMillan

• Place the EmailComposer.js file in your app root, and include it from your html.

• Add to Cordova.plist Plugins: key org.apache.cordova.emailComposer value EmailComposer
• Add to Cordova.plist Plugins: key EmailComposer value EmailComposer

• This is intended to also demonstrate how to pass arguments to native code using the options/map object.

• Please review the js file to understand the interface you can call, and reply with any questions.

Cordova.exec(null, null, "org.apache.cordova.emailComposer", "showEmailComposer", [args]);
Cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]);

0 comments on commit a9a4d05

Please sign in to comment.