Skip to content

Commit 553b91f

Browse files
author
Sylvain Boily
committed
sync with master
2 parents 3a88d06 + 8e56b0a commit 553b91f

File tree

13 files changed

+669
-286
lines changed

13 files changed

+669
-286
lines changed

MIGRATION_v3_v4.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Migration from CallKeep v3 to v4
2+
3+
The `reportNewIncomingCall` method on iOS is now more consistent.
4+
5+
Please update your `AppDelegate.m` file with this new signature:
6+
7+
```objc
8+
[RNCallKeep reportNewIncomingCall: uuidString
9+
handle: handle
10+
handleType: handleType
11+
hasVideo: YES
12+
localizedCallerName: localizedCallerName
13+
supportsHolding: YES
14+
supportsDTMF: YES
15+
supportsGrouping: YES
16+
supportsUngrouping: YES
17+
fromPushKit: YES
18+
payload: nil
19+
withCompletionHandler: nil];
20+
```

README.md

Lines changed: 119 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ const options = {
4747
cancelButton: 'Cancel',
4848
okButton: 'ok',
4949
imageName: 'phone_account_icon',
50-
additionalPermissions: [PermissionsAndroid.PERMISSIONS.example]
50+
additionalPermissions: [PermissionsAndroid.PERMISSIONS.example],
51+
// Required to get audio in background when using Android 11
52+
foregroundService: {
53+
channelId: 'com.company.my',
54+
channelName: 'Foreground service for my app',
55+
notificationTitle: 'My app is running on background',
56+
notificationIcon: 'Path to the resource icon of the notification',
57+
},
5158
}
5259
};
5360

@@ -63,7 +70,7 @@ RNCallKeep.setup(options).then(accepted => {});
6370
- `ringtoneSound`: string (optional)
6471
If provided, it will be played when incoming calls received; the system will use the default ringtone if this is not provided
6572
- `includesCallsInRecents`: boolean (optional)
66-
If provided, calls will be shown in the recent calls when true and not when false (ios 11 and above)
73+
If provided, calls will be shown in the recent calls when true and not when false (ios 11 and above) (Default: true)
6774
- `maximumCallGroups`: string (optional)
6875
If provided, the maximum number of call groups supported by this application (Default: 3)
6976
- `maximumCallsPerCallGroup`: string (optional)
@@ -124,6 +131,30 @@ Eg: When your used log out (or the connection to your server is broken, etc..),
124131
RNCallKeep.setAvailable(true);
125132
```
126133

134+
### setForegroundServiceSettings
135+
_This feature is available only on Android._
136+
137+
Configures the [Foreground Service](https://developer.android.com/about/versions/11/privacy/foreground-services) used for Android 11 to get microphone access on background.
138+
Similar to set the `foregroundService` key in the `setup()` method.
139+
140+
```js
141+
RNCallKeep.setForegroundServiceSettings({
142+
channelId: 'com.company.my',
143+
channelName: 'Foreground service for my app',
144+
notificationTitle: 'My app is running on background',
145+
notificationIcon: 'Path to the resource icon of the notification',
146+
});
147+
```
148+
149+
### canMakeMultipleCalls
150+
_This feature is available only on Android._
151+
152+
Disable the "Add call" button in ConnectionService UI.
153+
154+
```js
155+
RNCallKeep.canMakeMultipleCalls(false); // Enabled by default
156+
```
157+
127158
- `active`: boolean
128159
- Tell whether the app is ready or not
129160

@@ -156,13 +187,33 @@ RNCallKeep.isCallActive(uuid);
156187
- `uuid`: string
157188
- The `uuid` used for `startCall` or `displayIncomingCall`
158189

190+
191+
### getCalls
192+
193+
_This feature is available only on IOS._
194+
195+
Returns a Promise. The result will be an array with all current calls and their states.
196+
197+
```js
198+
RNCallKeep.getCalls();
199+
200+
response:
201+
[{
202+
callUUID: "E26B14F7-2CDF-48D0-9925-532199AE7C48"
203+
hasConnected: true
204+
hasEnded: false
205+
onHold: false
206+
outgoing: false
207+
}]
208+
```
209+
159210
### displayIncomingCall
160211

161212
Display system UI for incoming calls
162213

163-
````js
214+
```js
164215
RNCallKeep.displayIncomingCall(uuid, handle, localizedCallerName);
165-
````
216+
```
166217

167218
- `uuid`: string
168219
- An `uuid` that should be stored and re-used for `stopCall`.
@@ -177,9 +228,15 @@ RNCallKeep.displayIncomingCall(uuid, handle, localizedCallerName);
177228
- `hasVideo`: boolean (optional, iOS only)
178229
- `false` (default)
179230
- `true` (you know... when not false)
231+
- `options`: object (optional)
232+
- `ios`: object
233+
- `supportsHolding`: boolean (optional, default true)
234+
- `supportsDTMF`: boolean (optional, default true)
235+
- `supportsGrouping`: boolean (optional, default true)
236+
- `supportsUngrouping`: boolean (optional, default true)
237+
- `android`: object (currently no-op)
180238

181239
### answerIncomingCall
182-
_This feature is available only on Android._
183240

184241
Use this to tell the sdk a user answered a call from the app UI.
185242

@@ -232,6 +289,14 @@ RNCallKeep.updateDisplay(uuid, displayName, handle)
232289
- Name of the caller to be displayed on the native UI
233290
- `handle`: string
234291
- Phone number of the caller
292+
- `options`: object (optional)
293+
- `ios`: object
294+
- `hasVideo`: boolean (optional)
295+
- `supportsHolding`: boolean (optional)
296+
- `supportsDTMF`: boolean (optional)
297+
- `supportsGrouping`: boolean (optional)
298+
- `supportsUngrouping`: boolean (optional)
299+
- `android`: object (currently no-op)
235300

236301
### endCall
237302

@@ -388,6 +453,29 @@ const options = {
388453
RNCallKeep.hasDefaultPhoneAccount(options);
389454
```
390455

456+
### checkPhoneAccountEnabled
457+
458+
Checks if the user has set a default [phone account](https://developer.android.com/reference/android/telecom/PhoneAccount) and it's enabled.
459+
460+
It's useful for custom permission prompts. It should be used in pair with `registerPhoneAccount`
461+
Similar to `hasDefaultPhoneAccount` but without trigering a prompt if the user doesn't have a phone account.
462+
463+
_This feature is available only on Android._
464+
465+
```js
466+
RNCallKeep.checkPhoneAccountEnabled();
467+
```
468+
469+
### isConnectionServiceAvailable
470+
471+
Check if the device support ConnectionService.
472+
473+
_This feature is available only on Android._
474+
475+
```js
476+
RNCallKeep.checkPhoneAccountEnabled();
477+
```
478+
391479
### backToForeground
392480
_This feature is available only on Android._
393481

@@ -538,9 +626,14 @@ Called as soon as JS context initializes if there were some actions performed by
538626

539627
Since iOS 13, you must display incoming call on receiving PushKit push notification. But if app was killed, it takes some time to create JS context. If user answers the call (or ends it) before JS context has been initialized, user actions will be passed as events array of this event. Similar situation can happen if user would like to start a call from Recents or similar iOS app, assuming that your app was in killed state.
540628

629+
**NOTE: You still need to subscribe / handle the rest events as usuall. This is just a helper whcih cache and propagate early fired events if and only if for "the native events which DID fire BEFORE js bridge is initialed", it does NOT mean this will have events each time when the app reopened.**
630+
541631
```js
632+
// register `didLoadWithEvents` somewhere early in your app when it is ready to handle callkeep events.
633+
542634
RNCallKeep.addEventListener('didLoadWithEvents', (events) => {
543-
// see example usage in https://github.com/react-native-webrtc/react-native-callkeep/pull/169
635+
// `events` is passed as an Array chronologically, handle or ignore events based on the app's logic
636+
// see example usage in https://github.com/react-native-webrtc/react-native-callkeep/pull/169 or https://github.com/react-native-webrtc/react-native-callkeep/pull/205
544637
});
545638
```
546639

@@ -724,7 +817,7 @@ In some case your application can be unreachable :
724817
- when the user kill the application
725818
- when it's in background since a long time (eg: after ~5mn the os will kill all connections).
726819

727-
To be able to wake up your application to display the incoming call, you can use [https://github.com/ianlin/react-native-voip-push-notification](react-native-voip-push-notification) on iOS or BackgroundMessaging from [react-native-firebase](https://rnfirebase.io/docs/v5.x.x/messaging/receiving-messages#4)-(Optional)(Android-only)-Listen-for-FCM-messages-in-the-background).
820+
To be able to wake up your application to display the incoming call, you can use [https://github.com/ianlin/react-native-voip-push-notification](react-native-voip-push-notification) on iOS or BackgroundMessaging from [react-native-firebase](https://rnfirebase.io/messaging/usage#receiving-messages)-(Optional)(Android-only)-Listen-for-FCM-messages-in-the-background).
728821

729822
You have to send a push to your application, like with Firebase for Android and with a library supporting PushKit pushes for iOS.
730823

@@ -743,10 +836,28 @@ Since iOS 13, you'll have to report the incoming calls that wakes up your applic
743836
// NSString *handle = @"caller number here";
744837
// NSDictionary *extra = [payload.dictionaryPayload valueForKeyPath:@"custom.path.to.data"]; /* use this to pass any special data (ie. from your notification) down to RN. Can also be `nil` */
745838

746-
[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES payload:extra withCompletionHandler:completion];
839+
[RNCallKeep reportNewIncomingCall: uuid
840+
handle: handle
841+
handleType: @"generic"
842+
hasVideo: NO
843+
localizedCallerName: callerName
844+
supportsHolding: YES
845+
supportsDTMF: YES
846+
supportsGrouping: YES
847+
supportsUngrouping: YES
848+
fromPushKit: YES
849+
payload: extra
850+
withCompletionHandler: completion];
747851
}
748852
```
749853

854+
## Android 11
855+
856+
Since Android 11, your application [requires to start a foregroundService](https://developer.android.com/about/versions/11/privacy/foreground-services) in order to access the microphone in background.
857+
You'll need to upgrade your `compileSdkVersion` to `30` to be able to use this feature.
858+
859+
You have to set the `foregroundService` key in the [`setup()`](#setup) method and add a `foregroundServiceType` in the [`AndroidManifest` file](docs/android-installation.md#android-common-step-installation).
860+
750861
## Debug
751862

752863
### Android

android/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<uses-permission android:name="android.permission.CALL_PHONE" />
55
<uses-permission android:name="android.permission.CAMERA" />
6-
<uses-permission android:name="READ_PHONE_STATE"
6+
<uses-permission android:name="android.permission.READ_PHONE_STATE"
77
android:maxSdkVersion="29" />
8-
<uses-permission android:name="READ_PHONE_NUMBERS" />
8+
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
99
</manifest>

android/src/main/java/io/wazo/callkeep/Constants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@ public class Constants {
1717
public static final String EXTRA_CALL_UUID = "EXTRA_CALL_UUID";
1818
public static final String EXTRA_CALLER_NAME = "EXTRA_CALLER_NAME";
1919
public static final String EXTRA_HAS_VIDEO = "EXTRA_HAS_VIDEO";
20+
// Can't use telecom.EXTRA_DISABLE_ADD_CALL ...
21+
public static final String EXTRA_DISABLE_ADD_CALL = "android.telecom.extra.DISABLE_ADD_CALL";
22+
public static final int FOREGROUND_SERVICE_TYPE_MICROPHONE = 128;
2023
}

0 commit comments

Comments
 (0)