phonegap/phonegap-plugins — Issue #358: Email Composer Plugin Issue when Emails are not Setup
Author: GeekTantra
Created: 2012-02-18 02:46:40+00:00
State: open

When no emails are setup on the device the Email Composer Plugin shows an alert only for the first time. When we setup the email and execute the "showEmailComposer" or "showEmailComposerWithCB" it does not work.

We can solve this by making the following patch in the EmailComposer.m code:

@@ -15,7 +15,7 @@
- (void) showEmailComposer:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
{
// NSUInteger argc = [arguments count];
-
+	if([MFMailComposeViewController canSendMail]){
NSString* toRecipientsString = [options valueForKey:@"toRecipients"];
NSString* ccRecipientsString = [options valueForKey:@"ccRecipients"];
NSString* bccRecipientsString = [options valueForKey:@"bccRecipients"];
@@ -64,6 +64,15 @@

[[ super appViewController ] presentModalViewController:picker animated:YES];
[picker release];
+ } else {
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No email accounts detected"
+	message:@"No email accounts are setup or are active on this device. Please setup an email account to use this feature."
+	delegate:nil
+	cancelButtonTitle:@"OK"
+	otherButtonTitles:nil];
+	[alert autorelease];
+	[alert show];
+ }
}