2010-10-22 122 views
1

在我的应用程序,我有一个日志机制,它提供的可能性,以客户通过mail.For这个发送日志,我综合我的应用程序的苹果MFMailComposeViewController。如果客户使用低操作系统版本(2.x)的设备或电子邮件帐户没有出现在设备上,我推送了一些UIAlertsView给用户一些提示性消息。有人可以看看我的下面的代码,并回答是否有什么可能导致苹果拒绝?MFMailComposeViewController使用和苹果aproval过程

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:@"[email protected]" 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:@"[email protected]" 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]; 

非常感谢,

亚历克斯。

回答

2

我不会说的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 
... 

P.S.不要忘记,在目标设置中,您必须将MessageUI框架的链接类型设置为“弱” - 如果您的链接类型为“必需”(默认值),则您的应用程序将在开始时在旧系统上崩溃。

+0

谢谢,弗拉基米尔。我没有想到这个 - 确实会崩溃:)。 – 2010-10-22 12:28:15