Help with EmailComposer

723 views
Skip to first unread message

b1p

unread,
Feb 21, 2011, 2:57:39 PM2/21/11
to phonegap
I read all the posts but can't make it work. Pretty sure I'm missing
something very basic.

What I've done:
1. Added the .m & .h files like so:

2. Added MessageUI.framework to the project like so:

3. This is 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>

When I click the link nothing happens.
Can anyone shed some light on this?

Jesse MacFadyen

unread,
Feb 21, 2011, 3:32:51 PM2/21/11
to phon...@googlegroups.com, b1p
Did you put EmailComposer.js in the www folder on the filesystem?
The rest looks good.

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com



--
--
Jesse MacFadyen
{
  blog:'blogs.nitobi.com/jesse',
  email:'jesse.m...@nitobi.com',
  company:
  {
    name:'Nitobi Software',
    site:'www.nitobi.com',
    phone:
    {
      office:'+1 (604) 685-9287',
      tollFree:'1-866-632-2777'
     }
  }
}

b1p

unread,
Feb 21, 2011, 3:37:23 PM2/21/11
to phonegap
Yep, I did.

Maybe I'm missing something in xCode? I'm not sure I understand the
idea behind "adding existing files" for the .m & .h....

On Feb 21, 10:32 pm, Jesse MacFadyen <jesse.macfad...@nitobi.com>
wrote:
>   email:'jesse.macfad...@nitobi.com',

ScottP

unread,
Feb 21, 2011, 4:17:29 PM2/21/11
to phonegap
If you throw an alert into doEmail() does it fire? Is the function
being called at all?
I see you have the json2.js in the includes but I had to physically
download and copy it to my www folder. Did you do that? (Especially if
you are running on iOS 3.x.)
Other than that - I agree, everything else looks ok.
> > }- Hide quoted text -
>
> - Show quoted text -

Jesse MacFadyen

unread,
Feb 21, 2011, 4:49:39 PM2/21/11
to phon...@googlegroups.com, ScottP
Any native code source files ( .m / .h ) need to be added to the project in XCode so the build process can link against them.  
Any files that reside inside the www folder are automatically packaged with the app, and should NOT be added to the XCode project, because XCode will consider them resources and move them to the root of your app.

After you have verified that your function is being called, via Scott's method, you can see if native code is being called by opening EmailComposer.m in XCode and putting a break-point inside the showEmailComposer method.  Then Build+Debug and see if you hit the breakpoint.

Hope this helps.

b1p

unread,
Feb 23, 2011, 3:55:36 PM2/23/11
to phonegap
Thanks guys! It was indeed related to the .m & .h files.

The documentation is not very clear about these.


On Feb 21, 11:49 pm, Jesse MacFadyen <jesse.macfad...@nitobi.com>
wrote:

kenny

unread,
Apr 24, 2011, 7:03:20 AM4/24/11
to phonegap
Hi all this might me a daft question but what do you mean when you say
try adding the message ui framework.

I cant seem to get the email plugin to work :(

any help would be much greatful

kenny

unread,
Apr 24, 2011, 7:07:31 AM4/24/11
to phonegap
never mind I found it, yay that really was easy to install, even for a
novice like me.

thank you

WellAppy

unread,
Sep 11, 2013, 9:41:12 AM9/11/13
to phon...@googlegroups.com
I have an almost identical setup with the same error - nothing happens! 

I have a console.log in the doEmail function, which is firing ok, and I know the .m and .h files are loading because it came up with an error about DLog so I changed it to NSlog instead and the error went away.

Any ideas what I could do? 
Reply all
Reply to author
Forward
0 new messages