My software has code that makes a telephone name, however first asks the person for permission. I want permission to be obtained immediately through the name, if doable.
Future<void> _makePhoneCall() async {
if (Platform.isAndroid) {
closing callPermissionStatus = await Permission.telephone.request();
if (callPermissionStatus.isGranted) {
closing String userPhone = contactPhone;
strive {
const MethodChannel('caller').invokeMethod('makeCall', userPhone);
} on PlatformException catch (e) {
Fluttertoast.showToast(
msg: AppLocalizations.occasion.translate("failedToCallTheNumber") +
("$contactPhone, ${e.message}"),
);
}
} else {
Fluttertoast.showToast(
msg: AppLocalizations.occasion.translate("failedToCallTheNumber") +
("$contactPhone"),
);
}
} else if (Platform.isIOS) {
closing callPermissionStatus = await Permission.telephone.request();
if (callPermissionStatus.isGranted) {
closing String userPhone = contactPhone;
strive {
const MethodChannel('caller')
.invokeMethod('makeCall', userPhone);
} on PlatformException catch (e) {
Fluttertoast.showToast(
msg: AppLocalizations.occasion.translate("failedToCallTheNumber") +
(" $contactPhone, ${e.message}"),
);
}
} else {
closing String userPhone = contactPhone;
Fluttertoast.showToast(
msg: AppLocalizations.occasion.translate("failedToCallTheNumber") +
(" $userPhone"),
);
}
}
}
This code works effective on Android, however on iOS there is no such thing as a dialog field asking the person for permission. I am utilizing permission_handler: ^11.3.1
however within the documentation for permission_handler: ^11.3.1 I discovered an outline for the “telephone” –
/// Permission for accessing the machine's telephone state (Android solely). static const telephone = PermissionWithService._(8);
What ought to I exploit as an alternative of “telephone” to open the telephone name permission dialog for iOS?
Or ought to I exploit one other library slightly than permission_handler?
My flutter physician –
Physician abstract (to see all particulars, run flutter physician -v):
[✓] Flutter (Channel secure, 3.19.5, on macOS 14.4.1 23E224 darwin-arm64, locale ru-UA)
[✓] Android toolchain - develop for Android gadgets (Android SDK model 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the net
[✓] Android Studio (model 2023.2)
[✓] VS Code (model 1.87.2)
[✓] VS Code (model 1.87.2)
[✓] Linked machine (3 accessible)
[✓] Community assets
• No points discovered!
for those who substitute in line –
closing callPermissionStatus = await Permission.telephone.request();
- “telephone” with “contacts” – then a dialog field seems asking for permission to entry contacts.
I additionally added these traces to the information.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>wanted to make telephone calls</string>
</array>
<key>NSCallKitUsageDescription</key>
<string>Name entry permission is required to make calls.</string>
<key>NSContactsUsageDescription</key>
<string>Permission to entry contacts is required to make calls.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Permission to entry the microphone is required to make calls.</string>
I am undecided if all these traces are wanted, I attempted so as to add every part to permit a telephone name to be made.