Created
August 12, 2013 15:00
-
-
Save xandrucea/6211586 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Send email | |
---------- | |
- (IBAction)btFeedback:(id)sender { | |
if ([MFMailComposeViewController canSendMail]) { | |
NSString *infoString = | |
[NSString stringWithFormat:@"\n\nUserid: %@ \nUsername: %@ \nIsPush enabled: %@", | |
_userId, | |
_userName, | |
[[NSUserDefaults standardUserDefaults] objectForKey:@"deviceToken" ]]; | |
MFMailComposeViewController* viewController = [[MFMailComposeViewController alloc] init]; | |
viewController.mailComposeDelegate = (id)self; | |
[viewController setSubject:@"Subject"]; | |
[viewController setMessageBody:infoString isHTML:NO]; | |
[viewController setToRecipients:[NSArray arrayWithObject:@"[email protected]"]]; | |
[_actualView presentViewController:viewController animated:YES completion:nil]; | |
} | |
} | |
- inserting delegate method | |
- (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 | |
[_actualView dismissViewControllerAnimated:YES completion:NULL]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment