MFMailComposeViewController用法和Apple批准过程

时间:2010-10-22 12:08:52

标签: iphone mfmailcomposeviewcontroller appstore-approval

在我的应用程序中,我有一个日志机制,它为客户提供了通过邮件发送日志的可能性。为此,我在我的应用程序中集成了Apple MFMailComposeViewController。如果客户使用低操作系统版本(2.x)的设备或设备上没有显示电子邮件帐户,我会向用户推送一些带有一些暗示性消息的UIAlertsView。有人可以看看我的下面的代码,并回复是否有可能导致苹果拒绝的事情?

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];

非常感谢,

亚历。

1 个答案:

答案 0 :(得分:2)

我不会说appstore的入场/拒绝但你的代码必须在iPhone OS 2.x上崩溃 - 你打电话

BOOL canSendmail = [MFMailComposeViewController canSendMail];

不检查是否可以进行此调用(2.x系统上没有MFMailComposeViewController类)。手动检查操作系统版本也不是一个好习惯。相反,您必须首先检查当前运行时是否存在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框架的链接类型设置为“弱” - 如果链接类型为“required”(默认值),则应用程序将在启动时在旧系统上崩溃。