Open elbriga opened 1 year ago
Use this Working Function
`
Future
final bool hasPhoneAccount = await _callKeep.hasPhoneAccount();
if (!hasPhoneAccount) {
await _callKeep.hasDefaultPhoneAccount(context, <String, dynamic>{
'alertTitle': 'Permissions required',
'alertDescription':
'This application needs to access your phone accounts',
'cancelButton': 'Cancel',
'okButton': 'ok',
'additionalPermissions': <String>[], // ADD Empty String array
'foregroundService': {
'channelId': 'com.company.my',
'channelName': 'Foreground service for my app',
'notificationTitle': 'My app is running on background',
'notificationIcon': 'Path to the resource icon of the notification',
},
});
}
print('[displayIncomingCall] $callUUID number: $number');
_callKeep.displayIncomingCall(callUUID, number,
handleType: 'number', hasVideo: false);
}
Also required READ_PHONE_NUMBERS permission
`
`
Thanks, I've found the answer too:
Just add: if (await Permission.phone.request().isGranted) { print('OKkkkkkkkkkkkk'); } else { print('ERROoooooooooo'); } just before the callkeep setup()
I call setup as in the example, to acquire permissions. The first time a run the App the permissions are asked.
When I call "displayIncomingCall" the Excpetion is thrown: