Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show System Alert "No Mail Accounts"

Currently I am using [MFMailComposeViewController canSendMail] to check if there exists some Account in Device. If Not I wish to show some Alert.

I saw an app of same kind which gives the alert "No Mail Accounts" in Localized Language.

I want the same Alert which should also be localized.

Is it some system Alert Or Will I have to create a custom with all localization strings?

Here is the exact implementation I am using

if (![MFMailComposeViewController canSendMail])
   return nil;
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
if(mailViewController)
{
      //Setting Email Stuff
}
like image 887
Ganesh Somani Avatar asked Oct 22 '22 04:10

Ganesh Somani


1 Answers

It's a system message, so you don't have to localize it, it will be displayed in the correct language if your project contains that language

            Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
            if (mailClass != nil)
            {
                MFMailComposeViewController *vc = [[[MFMailComposeViewController alloc] init] autorelease];
                if (vc!=nil) {
                    [vc setSubject:@"Mail subject"];

                    NSMutableString * message = @"mail message";

                    [vc setMessageBody:message isHTML:YES];


                    vc.mailComposeDelegate = self;

                    [self presentModalViewController:vc animated:YES];
                }

            }
            else
            {
                //Device doesn't include mail class, so it can't send mails
            }

Don't check the canSendMail and the device will show the no accounts alert when you try to send the message

like image 65
jcesarmobile Avatar answered Nov 03 '22 23:11

jcesarmobile