Iphone MFMailComposeViewController的使用和Apple Approval过程
在我的应用程序中,我有一个日志机制,可以让客户通过邮件发送日志。为此,我在我的应用程序中集成了Apple MFMailComposeViewController。如果客户使用操作系统版本(2.x)较低的设备,或者设备上没有显示电子邮件帐户,我会推送一些UIAlertsView,并向用户发送一些建议性消息。有人能看一下我下面的代码吗?如果有什么东西可能会被苹果公司拒绝,请回答Iphone MFMailComposeViewController的使用和Apple Approval过程,iphone,mfmailcomposeviewcontroller,appstore-approval,Iphone,Mfmailcomposeviewcontroller,Appstore Approval,在我的应用程序中,我有一个日志机制,可以让客户通过邮件发送日志。为此,我在我的应用程序中集成了Apple MFMailComposeViewController。如果客户使用操作系统版本(2.x)较低的设备,或者设备上没有显示电子邮件帐户,我会推送一些UIAlertsView,并向用户发送一些建议性消息。有人能看一下我下面的代码吗?如果有什么东西可能会被苹果公司拒绝,请回答 BOOL canSendmail = [MFMailComposeViewController canSendMail];
BOOL canSendmail = [MFMailComposeViewController canSendMail];
if (!canSendmail) {
NSMutableString* osVersion = [NSMutableString stringWithString:[[UIDevice currentDevice] systemVersion]];
EventsLog* logs = [EventsLog getInstance];
if ([osVersion characterAtIndex : 0] == '2' || [osVersion characterAtIndex : 0] == '1' ) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Email", @"")
message:NSLocalizedString(@"Failed to send E-mail.For this service you need to upgrade the iPhone OS to 3.0 version or later", @"")
delegate:self cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles: nil];
[alert show];
[alert release];
[logs writeEvent : @"Cannot send e-mail - iPhone OS needs upgrade to at least 3.0 version" classSource:@"LogsSessionDetailViewController@sendEmail" details : (@" device OS version is %@",osVersion)];
return;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Email", @"")
message:NSLocalizedString(@"Failed to send E-mail.Please set an E-mail account and try again", @"")
delegate:self cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles: nil];
[alert show];
[alert release];
[logs writeEvent : @"Cannot send e-mail "
classSource:@"LogsSessionDetailViewController@sendEmail" details : @"- no e-mail account activated"];
return;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Email", @"")
message:NSLocalizedString(@"The data you are sending will be used to improve the application. You are free to add any personal comments in this e-mail", @"")
delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", @"") otherButtonTitles: nil];
[alert addButtonWithTitle:NSLocalizedString(@"Submit", @"")];
[alert show];
[alert release];
非常感谢,
Alex。我不会说appstore的许可/拒绝,但你的代码必须在iPhone OS 2.x上崩溃-你可以打电话
BOOL canSendmail = [MFMailComposeViewController canSendMail];
不检查此调用是否可行(MFMailComposeViewController类在2.x系统上不可用)。此外,手动检查操作系统版本也不是一个好的做法。相反,您必须首先检查当前运行时中是否存在MFMailComposeViewController
:
if ( !NSClassFromString(@"MFMailComposeViewController") ){
// Put code that handles OS 2.x version
return;
}
if (![MFMailComposeViewController canSendMail]){
// Put code that handles the case when mail account is not set up
return;
}
//Finally, create and send your log
...
注意:不要忘记,必须在目标设置中将MessageUI框架的链接类型设置为“弱”-如果链接类型为“必需”(默认值),则应用程序将在启动时在旧系统上崩溃 谢谢你,弗拉基米尔。我没有想到这一次——事实上那会崩溃:)。