[iOS] 아이폰 기본 메일 어플 열어주기
1. 기본 세팅 : Info.plist 에 mailto 스키마 추가
<key>LSApplicationQueriesSchemes</key>
<array>
<string>message</string>
<string>mailto</string>
</array>
2. 메일 앱을 열기
NSURL *url = [NSURL URLWithString:@"message:"];
if ([UIApplication.sharedApplication canOpenURL:url]) {
[UIApplication.sharedApplication openURL:url];
}
3. 메일 앱을 열어 보내는 화면까지
NSURL *url = [NSURL URLWithString:@"mailto:test@gmail.com"];
if ([UIApplication.sharedApplication canOpenURL:url]) {
[UIApplication.sharedApplication openURL:url];
}
단말에서 실행했을 경우,
iOS 12.2 : [Snapshotting] Snapshotting a view (0x102811a00, UIKeyboardImpl) that is not in a visible window requires afterScreenUpdates:YES.
앱이 죽진 않았지만 해당 에러가 났습니다.
시뮬레이션에서 실행했을 경우,
iOS 9.1 : canOpenURL: failed for URL: "mailto:" - error: "(null)"
iOS 12.2 :canOpenURL: failed for URL: "mailto:" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
앱이 죽진 않았지만 해당 에러가 나면서 메일 앱이 실행되지 않습니다.