MailCore2 SDK API
?聲明:由于MailCore2 SDK API眾多,所以將從功能使用的角度以及結合項目來闡述。
?
?(1) ? 郵件賬戶方面:我們需要驗證賬戶,驗證通過,則把該賬戶保存下來。
?郵件接收分IMAP和POP協議。
?
?checkAccountOperation
?
?
?- ? ? ? (MCOSMTPOperation *) checkAccountOperationWithFrom:(MCOAddress *)from;
?-
?(2) ? 驗證賬戶后,我們首先就是要獲取文件夾信息,
?MCOIMAPFolderInfoOperation類API用來獲取郵件文件夾的信息。----
?
?- ? ? ? (MCOIMAPFolderInfoOperation *) folderInfoOperation:(NSString *)folder;
?
?
?- ? ? ? (void) start:(void (^)(NSError * error, MCOIMAPFolderInfo * info))
?completionBlock;
?
?
?
?fetchAllFoldersOperation
?
?
?- (void) start:(void (^)(NSError * error, NSArray * folders))completionBlock;
?
?
?- (MCOIMAPFolderStatusOperation *) folderStatusOperation:(NSString *)folder;
?
?
?- ? ? ? (void) start:(void (^)(NSError * error, MCOIMAPFolderStatus * status))
?completionBlock;
?
?(3)IMAP API
?
?MCOIMAPSession類基本屬性和常用API
?
?@property (nonatomic, copy) NSString *hostname;
?
?
?@property (nonatomic, assign) unsigned int port;
?
?
?@property (nonatomic, copy) NSString *username;
?
?
?@property (nonatomic, copy) NSString *password;
?
?
?@property (nonatomic, copy) NSString *OAuth2Token;
?
?
?@property (nonatomic, assign) MCOAuthType authType;
?
?
?@property (nonatomic, assign) MCOConnectionType connectionType;
?
?- (MCOIMAPFetchFoldersOperation *) fetchSubscribedFoldersOperation;
?
?
?
?- ? ? ? (MCOIMAPOperation *) renameFolderOperation:(NSString *)folder otherName:(NSString *)otherName
?
?
?
?- ? ? ? (MCOIMAPOperation *) deleteFolderOperation:(NSString *)folder
?
?
?- ? ? ? (MCOIMAPOperation *) createFolderOperation:(NSString *)folder
?-
?
?- (MCOIMAPOperation *) subscribeFolderOperation:(NSString *)folder;
?
?
?
?
?
?
?
?- (MCOIMAPOperation *) expungeOperation:(NSString *)folder;
?
?
?- ? ? ? (MCOIMAPOperation *) unsubscribeFolderOperation:(NSString *)folder;
?
?
?- ? ? ? (MCOIMAPOperation *) expungeOperation:(NSString *)folder;
?
?
?
?- (MCOIMAPAppendMessageOperation
?*)appendMessageOperationWithFolder:(NSString *)folder
?messageData:(NSData *)messageData
?flags:(MCOMessageFlag)flags;
?
?
?- ? ? ? ? ? (MCOIMAPCopyMessagesOperation *)copyMessagesOperationWithFolder:(NSString *)folder? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? uids:(MCOIndexSet *)uids ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? destFolder:(NSString *)destFolder
?
?
?- (MCOIMAPOperation *) storeFlagsOperationWithFolder:(NSString *)folder
?uids:(MCOIndexSet *)uids
?kind:(MCOIMAPStoreFlagsRequestKind)kind
?flags:(MCOMessageFlag)flags;
?
?
?
?- (MCOIMAPOperation *) storeLabelsOperationWithFolder:(NSString *)folder
?uids:(MCOIndexSet *)uids
?kind:(MCOIMAPStoreFlagsRequestKind)kind
?labels:(NSArray *)labels;
?
?
?
?- ? ? ? (MCOIMAPFetchMessagesOperation *)
?fetchMessagesByUIDOperationWithFolder:(NSString *)folder
?requestKind:(MCOIMAPMessagesRequestKind)requestKind
?uids:(MCOIndexSet *)uids;
?
?
?- ? ? ? (MCOIMAPFetchMessagesOperation *)
?fetchMessagesByNumberOperationWithFolder:(NSString *)folder
?requestKind:(MCOIMAPMessagesRequestKind)requestKind
?numbers:(MCOIndexSet *)numbers;
?
?
?
?- ? ? ? (MCOIMAPFetchContentOperation *)
?fetchMessageByUIDOperationWithFolder:(NSString *)folder
?uid:(uint32_t)uid
?urgent:(BOOL)urgent;
?
?
?
?-? ? ? ? ? (MCOIMAPFetchContentOperation *) fetchMessageAttachmentByUIDOperationWithFolder:(NSString *)folder? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? uid:(uint32_t)uid ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? partID:(NSString *)partID? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? encoding:(MCOEncoding)encoding ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? urgent:(BOOL)urgent;
?
?
?
?- ? ? ? (MCOIMAPSearchOperation *) searchOperationWithFolder:(NSString *)folder? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? kind:(MCOIMAPSearchKind)kind? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? searchString:(NSString *)searchString;
?
?
?
?
?- ? ? ? (MCOIMAPSearchOperation *)
?searchExpressionOperationWithFolder:(NSString *)folder
?expression:(MCOIMAPSearchExpression *)expression;
?
?
?
?- ? ? ? (MCOIMAPMessageRenderingOperation *)
?htmlRenderingOperationWithMessage:(MCOIMAPMessage *)message
?folder:(NSString *)folder;
?
?
?
?- ? ? ? (MCOIMAPMessageRenderingOperation *)
?htmlBodyRenderingOperationWithMessage:(MCOIMAPMessage *)message
?folder:(NSString *)folder;
?
?
?
?- ? ? ? (MCOIMAPMessageRenderingOperation *)
?plainTextRenderingOperationWithMessage:(MCOIMAPMessage *)message ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? folder:(NSString *)folder;
?
?
?- (MCOIMAPMessageRenderingOperation *) plainTextBodyRenderingOperationWithMessage:(MCOIMAPMessage *)message
?folder:(NSString *)folder;
?
?(3) ? SMTP API
?其基本屬性和POP以及IMAP差不多,其主要功能是用來發送郵件。
?
?
?- ? ? ? (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData;
?
?
?
?
?
?
?- (MCOSMTPSendOperation *) sendOperationWithData:(NSData *)messageData
?from:(MCOAddress *)from
?recipients:(NSArray *)recipients;
?(4) ? POP API
?Pop會話的基本屬性和IMAP類似,但請求有所變化,與IMAP有諸多不同。
?
?
?- ? ? ? (MCOPOPFetchMessagesOperation *) fetchMessagesOperation;
?
?
?-? ? ? ? (MCOPOPFetchHeaderOperation *)
?fetchHeaderOperationWithIndex:(unsigned int)index;
?
?-? ? ? ? (MCOPOPFetchMessageOperation *)
?fetchMessageOperationWithIndex:(unsigned int)index;
?
?
?
?- (MCOPOPOperation *)
?deleteMessagesOperationWithIndexes:(MCOIndexSet *)indexes;
?
?
?-? ? ? ? (MCOPOPOperation *) disconnectOperation
?
?郵件列表加載函數調用順序說明:
?加載masterViewController后,開始加載郵件
?
?調用:
?-(void)loadEmail
?
?在loadEmail中,為了展示效果,首先從數據庫加載郵件,調用:
?- ? ? ? (void)loadEmailsWithCache:(BOOL)allowed,
?
?然后執行新的郵件檢測,調用:
?- (void)checkNewEmailShouldSynchnize
?而在這個函數中,我們要將上一次的郵件最大UID(已經緩存)和這一次的郵件最大UID做對比,如果存在差值,則證明有新郵件需要同步,否則直接返回,這樣加快速度。
?我們不知道哪些郵件需要同步,但我們肯定的是沒有郵件概要的需要我們去同步,所以,當上面的提到的差值大于0時,那么我們得重新獲取列表。拿到的就是最新的20封頭,我們會去檢測哪些是沒有緩存的,這二十封郵件都要檢測,是為了防止上次同步失敗,當我們獲得這個需要同步的郵件隊列后,用GCD開啟異步線程去加載郵件內容即調用:
?- ? ? ? (void)asynchronousDownloadAllMessagesContent:(NSArray*)filteredMessages,
?然后異步加載郵件body,調用:
?- ? ? ? (void)downloadAllMeasseagesContentByMessages:(NSArray *)filteredMessages
?AndFinishBlock:(ComplishBlock)finishBlock andIndex:(NSInteger)index
?獲取完成后,發送通知給Cell,由于cell攜帶email數據模型,對比下uid即可達到指定更新body的效果。
?當所有需要同步的郵件完成UI更新時(cell上body變化),將此郵件列表交由后臺處理,保存到數據庫,這樣FMDB不會占用主線程,所以郵件同步管理類調用:
?//本地同步郵件列表數據數據到數據庫
?-(void)synEmailToDB
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的MailCore2 SDK API的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LayaBox入门基础之JS代码实现按钮
- 下一篇: UITextField中复制和粘贴为中文