InAppWebView 6.0 버전 기준으로 작성했습니다.
web에서 mailto: 로 만들어둔 링크를 터치하면 아무 반응이 없다면
inAppWebView 에서 따로 처리해주어야합니다.
1. 안드로이드 설정
AndroidManifest.xml 에 다음과 같이 코드를 추가합니다.
이때, 꼭!!!!! application 밖에, uses-permission 과 같은 뎁스에서 작성해주셔야합니다.
저는 manifest 하단부분에 작성했습니다.

<queries>
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
</intent>
</queries>
2. iOS 설정
info.plist 에 다음 코드를 추가합니다.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>mailto</string>
</array>
3.
inAppWebView 위젯 Widget build(BuildContext context)
내부에서 다음과 같이 코드를 작성해주면 됩니다.
shouldOverrideUrlLoading: (controller, navigationAction) async {
var uri = navigationAction.request.url!;
if (uri.scheme == 'mailto') {
// Properly encode the mailto URL
final encodedSubject = Uri.encodeComponent(uri.queryParameters['subject'] ?? '');
final encodedBody = Uri.encodeComponent(uri.queryParameters['body'] ?? '');
final mailtoUri = Uri.parse('mailto:${uri.path}?subject=$encodedSubject&body=$encodedBody');
try {
if (await canLaunchUrl(mailtoUri)) {
await launchUrl(mailtoUri);
} else {
print("Could not launch $mailtoUri");
}
} catch (e) {
print("Error launching mail app: $e");
}
return NavigationActionPolicy.CANCEL;
}
return NavigationActionPolicy.ALLOW;
},
이렇게 설정해두면 링크 클릭시 메일 앱으로 연동됩니다.
'Flutter' 카테고리의 다른 글
[Flutter/iOS] InAppWebView whiteScreen / Touch Event not working / 웹뷰 흰 화면 에러 iOS 18.2+ (0) | 2025.02.10 |
---|---|
[Flutter] android/AOS Terminated/killed Heads-up notification 배너 알림 띄우기 (0) | 2024.10.08 |
[Flutter] Android InAppWebView download / 다운로드 구현 (1) | 2024.09.10 |
[Flutter] AndroidID 확인방법 / android SSAID 확인 방법 (2) | 2024.09.10 |
[Flutter] iOS app badge count handle / iOS 배지 숫자 제어 (4) | 2024.08.30 |