Reputation: 865
How can I write my iOS program so that when I click on an 'email developer for support' button, the generated email text would contain useful things to the developer such as:
1- Version of App
2- Version of iOS
3- Model of iPhone (or iPad)
It seems like this would be a pre-requisite minimum for any support call and very useful to have when fielding issues from customers.
Update: Just to be clear, I know how to write a program to generate the email. I am just interested in obtaining the above mentioned items and including them automatically in the email.
Upvotes: 0
Views: 308
Reputation: 865
Thanks to FabKremer (and others) I was able to get this to work. Here is the code that runs when I press the 'send email ' button:
- (IBAction) sendButtonTapped:(id)sender
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController* mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"];//use your email address here
[mailController setToRecipients:toRecipients];
[mailController setSubject:@"Feedback"];
NSString* myversion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] ;NSLog (@"myversion:%@",myversion);
NSString* myios = [[UIDevice currentDevice] systemVersion];NSLog (@"myios:%@",myios);
NSLog(@"model: %@",deviceName());
NSString* theMessage = [NSString stringWithFormat:@"Version: %@\niOS: %@\nModel: %@\n\n ",myversion,myios,deviceName()];
[mailController setMessageBody:theMessage isHTML:NO];
[self presentViewController:mailController animated:YES completion:NULL];
}
else
{
NSLog(@"%@", @"Sorry, you need to setup mail first!");
}
NSLog(@"Email sent");
}
Upvotes: 1
Reputation: 2179
To get the version of the app:
[NSString stringWithFormat:@"Version %@ (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"], kRevisionNumber]
To get the iOS version:
[[UIDevice currentDevice] systemVersion]
To get the model of the phone:
With this library: http://github.com/erica/uidevice-extension/ you can do something like:
[[UIDevice currentDevice] platformString] // ex: @"iPhone 5"
Upvotes: 1