Permalink
Browse files

Email Composer (iOS) CDV 2.0 compliance

  • Loading branch information...
1 parent 2749a2a commit 682f3329c548057dcf2a337e68a1bd9a7180e1e5 @RandyMcMillan RandyMcMillan committed Jul 31, 2012
Showing with 51 additions and 73 deletions.
  1. +0 −4 iOS/EmailComposer/EmailComposer.h
  2. +51 −69 iOS/EmailComposer/index.html
@@ -8,11 +8,7 @@
#import <Foundation/Foundation.h>
#import <MessageUI/MFMailComposeViewController.h>
-#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVPlugin.h>
-#else
-#import "CDVPlugin.h"
-#endif
@interface EmailComposer : CDVPlugin < MFMailComposeViewControllerDelegate > {
@@ -1,72 +1,54 @@
<!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>
+ <!--
+ #
+ # Licensed to the Apache Software Foundation (ASF) under one
+ # or more contributor license agreements. See the NOTICE file
+ # distributed with this work for additional information
+ # regarding copyright ownership. The ASF licenses this file
+ # to you under the Apache License, Version 2.0 (the
+ # "License"); you may not use this file except in compliance
+ # with the License. You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing,
+ # software distributed under the License is distributed on an
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ # KIND, either express or implied. See the License for the
+ # specific language governing permissions and limitations
+ # under the License.
+ #
+ -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta name = "format-detection" content = "telephone=no"/>
+ <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width;" />
+ <link rel="stylesheet" type="text/css" href="css/index.css" />
+ <title>Hello Cordova</title>
+ </head>
+ <body>
+ <div class="app">
+ <h1>Apache Cordova™</h1>
+ <div id="deviceready">
+ <p class="status pending blink">Connecting to Device</p>
+ <p class="status complete blink hide">Device is Ready</p>
+ </div>
+ </div>
+ <script type="text/javascript" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" src="js/index.js"></script>
+ <script type="text/javascript" charset="utf-8" src="EmailComposer.js"></script>
+
+ <script type="text/javascript">
+ app.initialize();
+
+ var args;
+ // cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]);
+
+ </script>
+
+ <center><button onclick="cordova.exec(null, null, 'EmailComposer', 'showEmailComposer', [args]);">Compose Email</button></center>
+
+
+ </body>
</html>

3 comments on commit 682f332

@becomingGuru

Works great on both 1.9 and 2.0. Thanks.

Why is the ability to add attachments removed? (I am working to be able to attach PDFs, any pointers appreciated.)

@douglasdeodato

great plugin, i just wanna knwo how we can set auto the fields: to: subject: and insert some text in body of the email.

cheers.

@inorganik

Also wondering about attachments - I see that ability is removed now. I had it working in the previous version, but I had to make some edits to emailComposer.m to make it work with files created with the phonegap File api.

Please sign in to comment.