[英]iOS: How do I detect if an email has been successfully sent?
我正在嘗試檢查是否已發送電子郵件並顯示警報以使用戶知道。
我在下面嘗試了委托方法,但不幸的是,如果用戶也取消,它將顯示警報消息。 任何幫助將不勝感激和獎勵。
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error{
if (error) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:
[NSString stringWithFormat:@"Error %@", [error description]] delegate:self
cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alert show];
}
NSLog(@"email sent");
}
}
當該函數被調用時,這意味着電子郵件中發生了某些事情,因為MFMailComposeViewController
已完成。 要知道實際發生了什么,您必須查看result
的值,該值可以是以下任意一種:
MFMailComposeResultCancelled
MFMailComposeResultSaved
MFMailComposeResultSent
MFMailComposeResultFailed
就像rmaddy在評論中說的那樣,您無法100%確定電子郵件是實際發送的(可能會卡在發件箱中)。 MFMailComposeResultSent
表示的是,該電子郵件已發送到郵件應用程序,該應用程序將盡快將其發送。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.