katzer / cordova-plugin-email-composer

Edit and send email messages
Apache License 2.0
343 stars 333 forks source link

The plugin doesn't work on iOS 8.3 #105

Closed mmBs closed 8 years ago

mmBs commented 9 years ago

Please, let me know if you have the same issue - there is no exception or log, the plugin just doesn't work. If you have any solution, please let me know.

aherold commented 9 years ago

Hi, I just updated to 8.3 from 8.2 to test it out. My app is still sending an email with an attachment correctly. However, I did need to remove all calls to this plugin's isAvailable() function for Android 5 to work. I am seeing issues with other plugins though...

mmBs commented 9 years ago

Hey, thanks for the comment. You are right, the plugin works but in a situation when you upgraded your iOS to 8.3 and ran the same, already installed application built in SDK 8.2 environment. However, if you compile the app using the brand new iOS SDK 8.3, the plugin stops working.

aherold commented 9 years ago

Yikes, thanks for the heads up. I'll take a closer look next week.

cwcoleman commented 9 years ago

I'm also having an issue between iOS 8.1 and 8.3

jvjvjv commented 9 years ago

+1 on this issue!

To ensure that we are reporting correctly, I have tried to implement sending a file attachment. The email dialog opens correctly, but it does not attach my base64-encoded file.

janewang commented 9 years ago

+1 Email dialog isn't opening on iOS 8.3 and no logs. The same code works in older iOS version.

Separate issue: 'base64Encoding' is deprecated: first deprecated in iOS 7.0. Related to the above attachment not working. Change to cdv_base64Encoding should work.

timothyjasonwilliams commented 9 years ago

Here is a quick fix, you shouldn't do view related things in background threads. There is also a pending pull request with a try catch a [[MFMailComposeViewController alloc] init] that is below.

- (void) open:(CDVInvokedUrlCommand*)command
{
    _command = command;

    if (TARGET_IPHONE_SIMULATOR && IsAtLeastiOSVersion(@"8.0")) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Email-Composer Plug-in"
                                                        message:@"Plug-in cannot run on the iOS8 Simulator.\nPlease downgrade or use a physical device."
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];
        [alert show];
        [self execCallback];
        return;
    }

//    [self.commandDelegate runInBackground:^{
        NSArray* args = command.arguments;
        NSDictionary* properties = [args objectAtIndex:0];
        MFMailComposeViewController* draft;

        draft = [self getDraftWithProperties:properties];

        if (!draft) {
            [self execCallback];
            return;
        }

        [self openDraft:draft];
//    }];
}

and

- (MFMailComposeViewController*) getDraftWithProperties:(NSDictionary*)properties
{
    // Falls das Gerät kein Email Interface unterstützt
    if (![MFMailComposeViewController canSendMail]) {
        return NULL;
    }

    BOOL isHTML = [[properties objectForKey:@"isHtml"] boolValue];

    MFMailComposeViewController* draft;

    @try {
        draft = [[MFMailComposeViewController alloc] init];

        // Subject
        [self setSubject:[properties objectForKey:@"subject"] ofDraft:draft];
        // Body (as HTML)
        [self setBody:[properties objectForKey:@"body"] ofDraft:draft isHTML:isHTML];
        // Recipients
        [self setToRecipients:[properties objectForKey:@"to"] ofDraft:draft];
        // CC Recipients
        [self setCcRecipients:[properties objectForKey:@"cc"] ofDraft:draft];
        // BCC Recipients
        [self setBccRecipients:[properties objectForKey:@"bcc"] ofDraft:draft];
        // Attachments
        [self setAttachments:[properties objectForKey:@"attachments"] ofDraft:draft];

        draft.mailComposeDelegate = self;

        return draft;
    }
    @catch(NSException * e) {
        // do nothing, let user click on e-mail button one more time
        return NULL;
    }
}
ms88privat commented 9 years ago

+1

olebrun commented 9 years ago

+1

jimthedev commented 9 years ago

@katzer Is there any way we could do a new release that includes #110?

MacrofonoEstudio commented 9 years ago

Hi everyone, Someone solved it? Thanks!

pablomaurer commented 9 years ago

+1

thubold commented 9 years ago

+1

privetr commented 9 years ago

+1

katzer commented 8 years ago

A bit out of date - I am working on a new release. The build for iOS 9 and cordova-ios-4 now runs without an issue. Please reopen if you still encounter the problem.