반응형
Version
// pubspec.yaml에 추가합니다. 포스팅 당시 제가 사용한 버전은 6.1.4 입니다.
url_launcher: ^6.1.4
Android 설정
android - app - src - main - AndroidManifest.xml
<queries>
<!-- If your app opens https URLs -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<!-- If your app makes calls -->
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<!-- If your sends SMS messages -->
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="smsto" />
</intent>
<!-- If your app sends emails -->
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
ios 설정
<array>
<string>sms</string>
<string>tel</string>
<string>mailto</string>
<string>https</string>
<string>https</string>
</array>
WebView 코드
_openURL(Uri url) async {
if (!await launchUrl(
url,
mode: LaunchMode.inAppWebView,
webViewConfiguration: const WebViewConfiguration(
headers: <String, String>{'my_header_key': 'my_header_value'}),
)) {
// throw 'Could not launch $url';
}
}
Phone 코드
_makingPhoneCall() async {
var url = Uri.parse("tel:01011111111");
if (await canLaunchUrl(url)) {
await launchUrl(url);
} else {
throw 'Could not launch url $url';
}
}
Email 코드
_sendingMails() async {
var url = Uri.parse("mailto:kimiszero@test.com");
if (await canLaunchUrl(url)) {
await launchUrl(url);
} else {
throw 'Could not launch mail url $url';
}
}
SMS 코드
_sendingSMS() async {
var url = Uri.parse("sms:966738292");
if (await canLaunchUrl(url)) {
await launchUrl(url);
} else {
throw 'Could not launch sms url $url';
}
}
구현 화면
참고로 ios 시뮬레이터에서 phone, sms, mail은 테스트 되지 않습니다.
실기기를 사용하시거나 android 로 테스트를 진행해보시면 될 것 같습니다. 아직 테스트 못한 코드입니다. 🥲
반응형
'Flutter' 카테고리의 다른 글
[Flutter Favorite] cached_network_image 구현코드 (0) | 2022.07.20 |
---|---|
[Flutter Favorite] image_picker 예시코드 (0) | 2022.07.15 |
[Flutter Favorite] WebView화면에서 플러터 화면으로 돌아오기 구현 (0) | 2022.07.10 |
[Flutter] splash 화면 수정하는 방법 (0) | 2022.06.16 |
Flutter 버전 변경하기 downgrade (0) | 2022.06.08 |