简体   繁体   English

检查用户是否已登录邮件应用程序

[英]checking is user is signed in mail application

i need to know is there any way to check that the user has given an id in mail application so that i can notify the user before calling MFMailComposeViewController that you are not signed in or you have not given an email id in mail application.我需要知道是否有任何方法可以检查用户是否在邮件应用程序中提供了一个 id,以便我可以在调用 MFMailComposeViewController 之前通知用户您未登录或您没有在邮件应用程序中提供 email id。


You can check it by below code您可以通过以下代码检查它

Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
    // We must always check whether the current device is configured for sending emails
    if ([mailClass canSendMail])
    {
        [self displayComposerSheet];
    }
    else
    {
        UIAlertView *objAlert=[[UIAlertView alloc]initWithTitle:@"No Mail Account" message:@"Please create an account first for sending mail." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [objAlert show];
        [objAlert release];
    }
}
else
{
    UIAlertView *objAlert=[[UIAlertView alloc]initWithTitle:@"No Mail Account" message:@"Please create an account first for sending mail." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [objAlert show];
    [objAlert release];
}
canSendMail

Returns a Boolean indicating whether the current device is able to send email.返回一个 Boolean 指示当前设备是否能够发送 email。

 + (BOOL)canSendMail

Return Value返回值

YES if the device is configured for sending email or NO if it is not.如果设备配置为发送 email,则为 YES,否则为 NO。 Discussion讨论

You should call this method before attempting to display the mail composition interface.您应该在尝试显示邮件撰写界面之前调用此方法。 If it returns NO, you must not display the mail composition interface.如果返回NO,则不能显示邮件撰写界面。

if([MFMailComposeViewController canSendMail])
{
//do something
}
else
{
// cannot send mail
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM