mailcore2 imap 服务器使用代码如下
self.imapSession = [[MCOIMAPSessionalloc] init];
self.imapSession.hostname = hostname;
self.imapSession.port = 993;
self.imapSession.username = username;
self.imapSession.password = password;
if (oauth2Token != nil) {
self.imapSession.OAuth2Token = oauth2Token;
self.imapSession.authType = MCOAuthTypeXOAuth2;
}
self.imapSession.connectionType = MCOConnectionTypeTLS;
MasterViewController * __weak weakSelf = self;
self.imapSession.connectionLogger = ^(void * connectionID, MCOConnectionLogType type, NSData * data) {
@synchronized(weakSelf) {
if (type != MCOConnectionLogTypeSentPrivate) {
NSLog(@"event logged:%p %i withData: %@", connectionID, type, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
}
}
};
// Reset the inbox
self.messages = nil;
self.totalNumberOfInboxMessages = -1;
self.isLoading = NO;
self.messagePreviews = [NSMutableDictionarydictionary];
[self.tableViewreloadData];
NSLog(@"checking account");
self.imapCheckOp = [self.imapSessioncheckAccountOperation];
[self.imapCheckOp start:^(NSError *error) {
MasterViewController *strongSelf = weakSelf;
NSLog(@"finished checking account.");
if (error == nil) {
[strongSelf loadLastNMessages:NUMBER_OF_MESSAGES_TO_LOAD];
} else {
NSLog(@"error loading account: %@", error);
}
strongSelf.imapCheckOp = nil;
}];
然而当我使用iOS8.1 的设备时,报错信息(控制台打印如下所示)
checking account
2015-02-15 13:33:00.034 MailCoreTest[11997:2994016] event logged:0x176af480 0 withData: * OK [CAPABILITY IMAP4 IMAP4rev1 IDLE XAPPLEPUSHSERVICE ID UIDPLUS AUTH=LOGIN NAMESPACE] QQMail IMAP4Server ready
2015-02-15 13:33:00.554 MailCoreTest[11997:2994016] event logged:0x176af480 0 withData: (null)
2015-02-15 13:33:00.556 MailCoreTest[11997:2993951] finished checking account.
2015-02-15 13:33:00.557 MailCoreTest[11997:2993951] error loading account: Error Domain=MCOErrorDomain Code=5 "Unable to authenticate with the current session's credentials." UserInfo=0x176a7df0 {NSLocalizedDescription=Unable to authenticate with the current session's credentials.}
但是当我使用iOS8.0 的设备时,报错信息为:
checking account
2015-02-15 13:35:35.480 MailCoreTest[7931:1757698] finished checking account.
2015-02-15 13:35:35.481 MailCoreTest[7931:1757698] error loading account: Error Domain=MCOErrorDomain Code=1 "A stable connection to the server could not be established." UserInfo=0x547140 {NSLocalizedDescription=A stable connection to the server could not be established.}
希望有遇到过此问题的并且已经成功解决的人多多帮助,在此诚挚的感谢!