Created
January 9, 2013 18:57
-
-
Save mluton/4495817 to your computer and use it in GitHub Desktop.
iOS: Generate email compose screen pre-populated with system information
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
if ([MFMailComposeViewController canSendMail]) { | |
NSString *iosVersion = [[UIDevice currentDevice] systemVersion]; | |
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; | |
NSString *appVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"]; | |
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init]; | |
mailViewController.mailComposeDelegate = self; | |
mailViewController.modalPresentationStyle = UIModalPresentationFormSheet; | |
[mailViewController setToRecipients:@[@"[email protected]"]]; | |
[mailViewController setMessageBody:[NSString stringWithFormat:@"<br/><br/><hr size=1><strong>UTC Chart Information</strong><br/>App Version: %@<br/>iOS Version: %@<hr size=1>", appVersion, iosVersion] isHTML:YES]; | |
[self presentViewController:mailViewController animated:YES completion:nil]; | |
} | |
else { | |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Unable to Send Mail" message:@"No email accounts have been configured for this device. At least one email account is required to send feedback." delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; | |
[alert show]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment