Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29767

Send a mail programmatically in Sprite Kit

$
0
0

I've tried to send mails programmatically using the MessageUI framework. This is what I have in MyScene.m. When I call the method, a mail window opens. But when I cancel the mail or when I send the mail, it doesn't goes back to MyScene.

    #import <MessageUI/MessageUI.h>
    -(void)sendMail
{
    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
    mc.mailComposeDelegate = self;
    [mc setSubject:@"Subject"];
    [mc setMessageBody:@"Hello!" isHTML:NO];
    [mc setToRecipients:[NSArray arrayWithObject:@"my.email@gmail.com"]];

    // Present mail view controller on screen
    [self.view.window.rootViewController presentViewController:mc animated:YES completion:NULL];

}

- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Mail cancelled");
            break;
        case MFMailComposeResultSaved:
            NSLog(@"Mail saved");
            break;
        case MFMailComposeResultSent:
            NSLog(@"Mail sent");
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Mail sent failure: %@", [error localizedDescription]);
            break;
        default:
            break;
    }

    // Close the Mail Interface
    [self.view.window.rootViewController dismissViewControllerAnimated:YES completion:NULL];
}

Viewing all articles
Browse latest Browse all 29767

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>