Код: Выделить всё
Future _makePhoneCall() async {
if (Platform.isAndroid) {
final callPermissionStatus = await Permission.phone.request();
if (callPermissionStatus.isGranted) {
final String userPhone = contactPhone;
try {
const MethodChannel('caller').invokeMethod('makeCall', userPhone);
} on PlatformException catch (e) {
Fluttertoast.showToast(
msg: AppLocalizations.instance.translate("failedToCallTheNumber") +
("$contactPhone, ${e.message}"),
);
}
} else {
Fluttertoast.showToast(
msg: AppLocalizations.instance.translate("failedToCallTheNumber") +
("$contactPhone"),
);
}
} else if (Platform.isIOS) {
final callPermissionStatus = await Permission.phone.request();
if (callPermissionStatus.isGranted) {
final String userPhone = contactPhone;
try {
const MethodChannel('caller')
.invokeMethod('makeCall', userPhone);
} on PlatformException catch (e) {
Fluttertoast.showToast(
msg: AppLocalizations.instance.translate("failedToCallTheNumber") +
(" $contactPhone, ${e.message}"),
);
}
} else {
final String userPhone = contactPhone;
Fluttertoast.showToast(
msg: AppLocalizations.instance.translate("failedToCallTheNumber") +
(" $userPhone"),
);
}
}
}
но в документации к Permission_handler: ^11.3.1 я нашел описание "телефона" -
Код: Выделить всё
/// Permission for accessing the device's phone state (Android only). static const phone = PermissionWithService._(8); Или мне следует использовать другую библиотеку, а не Permission_handler?
Мой доктор флаттера -
Код: Выделить всё
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.5, on macOS 14.4.1 23E224 darwin-arm64, locale ru-UA)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] VS Code (version 1.87.2)
[✓] VS Code (version 1.87.2)
[✓] Connected device (3 available)
[✓] Network resources
• No issues found!
Код: Выделить всё
final callPermissionStatus = await Permission.phone.request();- "телефон" с "контактами" - затем появляется диалоговое окно с запросом разрешения на доступ к контактам.
Код: Выделить всё
LSApplicationQueriesSchemes
needed to make phone calls
NSCallKitUsageDescription
Call access permission is required to make calls.
NSContactsUsageDescription
Permission to access contacts is required to make calls.
NSMicrophoneUsageDescription
Permission to access the microphone is required to make calls.
Подробнее здесь: https://stackoverflow.com/questions/783 ... -flutter-a
Мобильная версия