Want to open mail setup in iphone whenever user doesnt have implemented any mail account in mail

StackOverflow https://stackoverflow.com/questions/9919530

  •  27-05-2021
  •  | 
  •  

문제

I have implemented mail composer. But it opens mail composer whenever user had implemented mail account in iphone. My requirement is If user had not implemented mail accont , the mail setup should be opened.

도움이 되었습니까?

해결책

Try this code...

      if ([mailClass canSendMail])
        {
            [self displayComposerSheet];
        }
        else
        {
               //open mail set up
            [self launchMailAppOnDevice];
        }

// Launches the Mail application on the device.
-(void)launchMailAppOnDevice
{
    NSString *recipients = @"mailto:first@example.com?cc=second@example.com,third@example.com&subject=Hello from California!";
    NSString *body = @"&body=It is raining in sunny California!";

    NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
    email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top