Skip to content

Commit a517c40

Browse files
author
Mikael Wills
committed
Updated README
1 parent db7a1bd commit a517c40

File tree

1 file changed

+44
-20
lines changed

1 file changed

+44
-20
lines changed

README.md

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,51 @@ This allows you (for example) to answer calls when your device is locked even if
2020
Basic configuration. In Android a popup is displayed before starting requesting some permissions to work properly.
2121

2222
```dart
23-
final callSetup = <String, dynamic>{
24-
'ios': {
25-
'appName': 'CallKeepDemo',
26-
},
27-
'android': {
28-
'alertTitle': 'Permissions required',
29-
'alertDescription':
30-
'This application needs to access your phone accounts',
31-
'cancelButton': 'Cancel',
32-
'okButton': 'ok',
33-
// Required to get audio in background when using Android 11
34-
'foregroundService': {
35-
'channelId': 'com.company.my',
36-
'channelName': 'Foreground service for my app',
37-
'notificationTitle': 'My app is running on background',
38-
'notificationIcon': 'mipmap/ic_notification_launcher',
39-
},
40-
},
41-
};
23+
callKeep.setup(
24+
showAlertDialog: () async {
25+
final BuildContext context = navigatorKey.currentContext!;
4226
43-
callKeep.setup(callSetup);
27+
return await showDialog<bool>(
28+
context: context,
29+
barrierDismissible: false,
30+
builder: (BuildContext context) {
31+
return AlertDialog(
32+
title: const Text('Permissions Required'),
33+
content: const Text(
34+
'This application needs to access your phone accounts'),
35+
actions: <Widget>[
36+
TextButton(
37+
child: const Text('Cancel'),
38+
onPressed: () => Navigator.of(context).pop(false),
39+
),
40+
TextButton(
41+
child: const Text('OK'),
42+
onPressed: () => Navigator.of(context).pop(true),
43+
),
44+
],
45+
);
46+
},
47+
) ??
48+
false;
49+
},
50+
options:<String, dynamic>{
51+
'ios': {
52+
'appName': 'CallKeepDemo',
53+
},
54+
'android': {
55+
'additionalPermissions': [
56+
'android.permission.CALL_PHONE',
57+
'android.permission.READ_PHONE_NUMBERS'
58+
],
59+
// Required to get audio in background when using Android 11
60+
'foregroundService': {
61+
'channelId': 'com.company.my',
62+
'channelName': 'Foreground service for my app',
63+
'notificationTitle': 'My app is running on background',
64+
'notificationIcon': 'mipmap/ic_notification_launcher',
65+
},
66+
},
67+
});
4468
```
4569

4670
This configuration should be defined when your application wakes up, but keep in mind this alert will appear if you aren't granting the needed permissions yet.

0 commit comments

Comments
 (0)