Skip to content

Commit 0eb8f36

Browse files
authored
Merge branch 'master' into master
2 parents 06d9543 + 70059bd commit 0eb8f36

File tree

5 files changed

+57
-69
lines changed

5 files changed

+57
-69
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ For more information about **ConnectionService** on Android, please see [Android
1515
- [Demo](#Demo)
1616
- [Installation](#Installation)
1717
- [Usage](#Usage)
18+
- [Expo](#Usage-with-Expo)
1819
- [Constants](#Constants)
1920
- [Android Self Managed](#Android-Self-Managed-Mode)
2021
- [API](#Api)
@@ -155,6 +156,10 @@ Alternative on iOS you can perform setup in `AppDelegate.m`. Doing this allows c
155156
156157
You can alternatively just call `setSettings()` with the same option as `setup()` to define only your settings.
157158
159+
# Usage with Expo
160+
161+
To use this library with Expo, you will need to create a development build. Expo Go does not support custom native modules. For information on how to create and run a development build, visit: [Create a development build - Expo Documentation](https://docs.expo.dev/develop/development-builds/create-a-build/). You can use and test this library with a development build installed on your physical device (iOS and Android).
162+
158163
# Constants
159164
160165
To make passing the right integer into methods easier, there are constants that are exported from the module.
@@ -1108,6 +1113,7 @@ class RNCallKeepExample extends React.Component {
11081113
}
11091114
```
11101115

1116+
11111117
## Receiving a call when the application is not reachable.
11121118

11131119
In some case your application can be unreachable :

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,11 +1079,11 @@ private WritableMap storeSettings(ReadableMap options) {
10791079
}
10801080

10811081
protected static void fetchStoredSettings(@Nullable Context fromContext) {
1082-
Context context = fromContext != null ? fromContext : instance.getAppContext();
1083-
if (instance == null && context == null) {
1082+
if (instance == null && fromContext == null) {
10841083
Log.w(TAG, "[RNCallKeepModule][fetchStoredSettings] no instance nor fromContext.");
10851084
return;
10861085
}
1086+
Context context = fromContext != null ? fromContext : instance.getAppContext();
10871087
_settings = new WritableNativeMap();
10881088
if (context == null) {
10891089
Log.w(TAG, "[RNCallKeepModule][fetchStoredSettings] no react context found.");

example/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export default function App() {
7777
const { [callUUID]: __, ...updatedHeldCalls } = heldCalls;
7878

7979
setCalls(updated);
80-
setCalls(updatedHeldCalls);
80+
setHeldCalls(updatedHeldCalls);
8181
};
8282

8383
const setCallHeld = (callUUID, held) => {

example/yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5520,9 +5520,9 @@ typedarray@^0.0.6:
55205520
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
55215521

55225522
ua-parser-js@^0.7.18, ua-parser-js@^0.7.19:
5523-
version "0.7.28"
5524-
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.28.tgz#8ba04e653f35ce210239c64661685bf9121dec31"
5525-
integrity sha512-6Gurc1n//gjp9eQNXjD9O3M/sMwVtN5S8Lv9bvOYBfKfDNiIIhqiyi01vMBO45u4zkDE420w/e0se7Vs+sIg+g==
5523+
version "0.7.33"
5524+
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.33.tgz#1d04acb4ccef9293df6f70f2c3d22f3030d8b532"
5525+
integrity sha512-s8ax/CeZdK9R/56Sui0WM6y9OFREJarMRHqLB2EwkovemBxNQ+Bqu8GAsUnVcXKgphb++ghr/B2BZx4mahujPw==
55265526

55275527
uglify-es@^3.1.9:
55285528
version "3.3.9"

index.d.ts

Lines changed: 45 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,4 @@
11
declare module 'react-native-callkeep' {
2-
export type Events =
3-
'didReceiveStartCallAction' |
4-
'answerCall' |
5-
'endCall' |
6-
'didActivateAudioSession' |
7-
'didDeactivateAudioSession' |
8-
'didDisplayIncomingCall' |
9-
'didToggleHoldCallAction' |
10-
'didPerformDTMFAction' |
11-
'didResetProvider' |
12-
'checkReachability' |
13-
'didPerformSetMutedCallAction' |
14-
'didChangeAudioRoute' |
15-
'didLoadWithEvents' |
16-
'showIncomingCallUi' |
17-
'silenceIncomingCall' |
18-
'createIncomingConnectionFailed';
19-
20-
export type InitialEvent<Event extends Events> = {
21-
name: NativeEvents[Event],
22-
data: EventHandlers[Event]
23-
}
24-
export type InitialEvents = Array<InitialEvent<Events>>;
25-
262
export type NativeEvents = {
273
didReceiveStartCallAction: 'RNCallKeepDidReceiveStartCallAction';
284
answerCall: 'RNCallKeepPerformAnswerCallAction';
@@ -34,44 +10,50 @@ declare module 'react-native-callkeep' {
3410
didToggleHoldCallAction: 'RNCallKeepDidToggleHoldAction';
3511
didChangeAudioRoute: 'RNCallKeepDidChangeAudioRoute';
3612
didPerformDTMFAction: 'RNCallKeepDidPerformDTMFAction';
37-
didLoadWithEvents: 'RNCallKeepDidLoadWithEvents';
3813
showIncomingCallUi: 'RNCallKeepShowIncomingCallUi';
3914
silenceIncomingCall: 'RNCallKeepOnSilenceIncomingCall';
4015
createIncomingConnectionFailed: 'RNCallKeepOnIncomingConnectionFailed';
4116
checkReachability: 'RNCallKeepCheckReachability';
4217
didResetProvider: 'RNCallKeepProviderReset';
18+
didLoadWithEvents: 'RNCallKeepDidLoadWithEvents';
4319
}
44-
export type EventHandlers = {
45-
didReceiveStartCallAction: (args: { handle: string, callUUID: string, name: string }) => void;
46-
answerCall: (args: { callUUID: string }) => void;
47-
endCall: (args: { callUUID: string }) => void;
48-
didActivateAudioSession: () => void;
49-
didDeactivateAudioSession: () => void;
50-
didDisplayIncomingCall: (args: {
51-
error?: string,
52-
errorCode?: 'Unentitled' | 'CallUUIDAlreadyExists' | 'FilteredByDoNotDisturb' | 'FilteredByBlockList' | 'Unknown',
53-
callUUID: string,
54-
handle: string,
55-
localizedCallerName: string,
56-
hasVideo: '1' | '0',
57-
fromPushKit: '1' | '0',
58-
payload: object,
59-
}) => void;
60-
didPerformSetMutedCallAction: (args: { muted: boolean, callUUID: string }) => void;
61-
didToggleHoldCallAction: (args: { hold: boolean, callUUID: string }) => void;
62-
didChangeAudioRoute: (args: {
20+
21+
export type InitialEvents = Array<{
22+
[Event in Events]: { name: NativeEvents[Event], data: EventsPayload[Event] }
23+
}[Events]>
24+
25+
export type Events = keyof NativeEvents;
26+
export type EventsPayload = {
27+
didReceiveStartCallAction: { handle: string, callUUID?: string, name?: string };
28+
answerCall: { callUUID: string };
29+
endCall: { callUUID: string };
30+
didActivateAudioSession: undefined;
31+
didDeactivateAudioSession: undefined;
32+
didDisplayIncomingCall: {
33+
error?: string,
34+
errorCode?: 'Unentitled' | 'CallUUIDAlreadyExists' | 'FilteredByDoNotDisturb' | 'FilteredByBlockList' | 'Unknown',
35+
callUUID: string,
36+
handle: string,
37+
localizedCallerName: string,
38+
hasVideo: '1' | '0',
39+
fromPushKit: '1' | '0',
40+
payload: object,
41+
};
42+
didPerformSetMutedCallAction: { muted: boolean, callUUID: string };
43+
didToggleHoldCallAction: { hold: boolean, callUUID: string };
44+
didChangeAudioRoute: {
6345
output: string,
6446
reason?: number,
6547
handle?: string,
6648
callUUID?: string,
67-
}) => void;
68-
didPerformDTMFAction: (args: { digits: string, callUUID: string }) => void;
69-
didLoadWithEvents: (args: { events: InitialEvents }) => void;
70-
showIncomingCallUi: (args: { handle: string, callUUID: string, name: string}) => void;
71-
silenceIncomingCall: (args: { handle: string, callUUID: string, name: string}) => void;
72-
createIncomingConnectionFailed: (args: { handle: string, callUUID: string, name: string}) => void;
73-
checkReachability: () => void;
74-
didResetProvider: () => void;
49+
};
50+
didPerformDTMFAction: { digits: string, callUUID: string };
51+
showIncomingCallUi: { handle: string, callUUID: string, name: string };
52+
silenceIncomingCall: { handle: string, callUUID: string, name: string };
53+
createIncomingConnectionFailed: { handle: string, callUUID: string, name: string };
54+
checkReachability: undefined;
55+
didResetProvider: undefined;
56+
didLoadWithEvents: InitialEvents;
7557
}
7658

7759
type HandleType = 'generic' | 'number' | 'email';
@@ -109,12 +91,6 @@ declare module 'react-native-callkeep' {
10991
}
11092
}
11193

112-
export type DidReceiveStartCallActionPayload = { handle: string };
113-
export type AnswerCallPayload = { callUUID: string };
114-
export type EndCallPayload = AnswerCallPayload;
115-
export type DidDisplayIncomingCallPayload = string | undefined;
116-
export type DidPerformSetMutedCallActionPayload = boolean;
117-
11894
export const CONSTANTS: {
11995
END_CALL_REASONS: {
12096
FAILED: 1,
@@ -137,7 +113,7 @@ declare module 'react-native-callkeep' {
137113

138114
static addEventListener<Event extends Events>(
139115
type: Event,
140-
handler: EventHandlers[Event],
116+
handler: (args: EventsPayload[Event]) => void,
141117
): EventListener
142118

143119
static removeEventListener(type: Events): void
@@ -202,18 +178,24 @@ declare module 'react-native-callkeep' {
202178

203179
static setReachable(): void
204180

205-
static setSettings(settings: Object): void;
181+
static setSettings(settings: IOptions): void;
206182

207183
/**
208184
* @description isCallActive method is available only on iOS.
209185
*/
210186
static isCallActive(uuid: string): Promise<boolean>
211187

212-
static getCalls(): Promise<object>
188+
static getCalls(): Promise<{
189+
callUUID: string,
190+
hasConnected: boolean,
191+
hasEnded: boolean,
192+
onHold: boolean,
193+
outgoing: boolean
194+
}[] | void>
213195

214196
static getAudioRoutes(): Promise<void>
215197

216-
static setAudioRoute: (uuid:string, inputName: string) => Promise<void>
198+
static setAudioRoute: (uuid: string, inputName: string) => Promise<void>
217199

218200
/**
219201
* @description supportConnectionService method is available only on Android.
@@ -257,7 +239,7 @@ declare module 'react-native-callkeep' {
257239
*/
258240
static setAvailable(active: boolean): void
259241

260-
static setForegroundServiceSettings(settings: Object): void
242+
static setForegroundServiceSettings(settings: NonNullable<IOptions['android']['foregroundService']>): void
261243

262244
static canMakeMultipleCalls(allow: boolean): void
263245

0 commit comments

Comments
 (0)