如何编写我的iOS程序,以便在我点击电子邮件开发人员获取支持时#按钮,生成的电子邮件文本将包含开发人员的有用信息,如:
1- App版本 2-版iOS版 3- iPhone(或iPad)型号
对于任何支持电话来说,这似乎都是先决条件的最低要求,并且在向客户提出问题时非常有用。
更新:为了清楚起见,我知道如何编写程序来生成电子邮件。我只是对获取上述项目感兴趣并将其自动包含在电子邮件中。
答案 0 :(得分:1)
获取应用的版本:
[NSString stringWithFormat:@"Version %@ (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"], kRevisionNumber]
获取iOS版本:
[[UIDevice currentDevice] systemVersion]
获取手机型号:
使用此库:http://github.com/erica/uidevice-extension/您可以执行以下操作:
[[UIDevice currentDevice] platformString] // ex: @"iPhone 5"
答案 1 :(得分:1)
感谢FabKremer(和其他人),我能够让它发挥作用。以下是按“发送电子邮件”按钮时运行的代码:
- (IBAction) sendButtonTapped:(id)sender
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController* mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
NSArray *toRecipients = [NSArray arrayWithObject:@"xxxx@xxxx.com"];//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");
}