Skip to content

Commit

Permalink
hasDefaultPhoneAccount give feedback about the user choice (#49)
Browse files Browse the repository at this point in the history
* fix: change parameter handle to number , call.argument("number") was undefined in HandleMethodCall for startCall case

* fix(ios): change handle to number

* feat: make hasDefaultPhoneAccount return a bool to have feedback on the telecom manager request
  • Loading branch information
Pierre-Monier authored Jan 29, 2021
1 parent 4aede74 commit 7f23ec4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/src/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,30 @@ class FlutterCallkeep extends EventManager {
return _channel.invokeMethod<void>('registerEvents', <String, dynamic>{});
}

Future<void> hasDefaultPhoneAccount(
Future<bool> hasDefaultPhoneAccount(
BuildContext context, Map<String, dynamic> options) async {
_context = context;
if (!isIOS) {
return _hasDefaultPhoneAccount(options);
return await _hasDefaultPhoneAccount(options);
}
return;

// return true on iOS because we don't want to block the endUser
return true;
}

Future<bool> _checkDefaultPhoneAccount() async {
return await _channel
.invokeMethod<bool>('checkDefaultPhoneAccount', <String, dynamic>{});
}

Future<void> _hasDefaultPhoneAccount(Map<String, dynamic> options) async {
Future<bool> _hasDefaultPhoneAccount(Map<String, dynamic> options) async {
final hasDefault = await _checkDefaultPhoneAccount();
final shouldOpenAccounts = await _alert(options, hasDefault);
if (shouldOpenAccounts == true) {
if (shouldOpenAccounts) {
await _openPhoneAccounts();
return true;
}
return false;
}

Future<void> displayIncomingCall(String uuid, String handle,
Expand Down

0 comments on commit 7f23ec4

Please sign in to comment.