2010-10-22 56 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