Skip to content

Commit 645abca

Browse files
committed
Minor updates
1 parent d46f174 commit 645abca

File tree

9 files changed

+90
-48
lines changed

9 files changed

+90
-48
lines changed

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,14 @@ Sets the Android caller name and number
187187
Use this to update the Android display after an outgoing call has started
188188

189189
```js
190-
RNCallKeep.updateDisplay(uuid, localizedCallerName, handle)
190+
RNCallKeep.updateDisplay(uuid, displayName, handle)
191191
```
192192
- `uuid`: string
193193
- The `uuid` used for `startCall` or `displayIncomingCall`
194+
- `displayName`: string (optional)
195+
- Name of the caller to be displayed on the native UI
194196
- `handle`: string
195197
- Phone number of the caller
196-
- `localizedCallerName`: string (optional)
197-
- Name of the caller to be displayed on the native UI
198-
199198

200199
### endCall
201200

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public class RNCallKeepModule extends ReactContextBaseJavaModule {
9191
private static final String[] permissions = { Manifest.permission.READ_PHONE_STATE,
9292
Manifest.permission.CALL_PHONE, Manifest.permission.RECORD_AUDIO };
9393

94-
private static final String TAG = "RNCallKeepModule";
94+
private static final String TAG = "RNCK:RNCallKeepModule";
9595
private static TelecomManager telecomManager;
9696
private static TelephonyManager telephonyManager;
9797
private static Promise hasPhoneAccountPromise;

example/App.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ const format = uuid => uuid.split('-')[0];
5454

5555
const getRandomNumber = () => String(Math.floor(Math.random() * 100000));
5656

57+
const isIOS = Platform.OS === 'ios';
58+
5759
export default function App() {
5860
const [logText, setLog] = useState('');
5961
const [heldCalls, setHeldCalls] = useState({}); // callKeep uuid: held
@@ -182,6 +184,18 @@ export default function App() {
182184
setCallMuted(callUUID, muted);
183185
};
184186

187+
const updateDisplay = (callUUID) => {
188+
const number = calls[callUUID];
189+
// Workaround because Android doesn't display well displayName, se we have to switch ...
190+
if (isIOS) {
191+
RNCallKeep.updateDisplay(callUUID, 'New Name', number);
192+
} else {
193+
RNCallKeep.updateDisplay(callUUID, number, 'New Name');
194+
}
195+
196+
log(`[updateDisplay: ${number}] ${format(callUUID)}`);
197+
};
198+
185199
useEffect(() => {
186200
RNCallKeep.addEventListener('answerCall', answerCall);
187201
RNCallKeep.addEventListener('didPerformDTMFAction', didPerformDTMFAction);
@@ -200,7 +214,7 @@ export default function App() {
200214
}
201215
}, []);
202216

203-
if (Platform.OS === 'ios' && DeviceInfo.isEmulator()) {
217+
if (isIOS && DeviceInfo.isEmulator()) {
204218
return <Text style={styles.container}>CallKeep doesn't work on iOS emulator</Text>;
205219
}
206220

@@ -224,6 +238,14 @@ export default function App() {
224238
<Text>{heldCalls[callUUID] ? 'Unhold' : 'Hold'} {calls[callUUID]}</Text>
225239
</TouchableOpacity>
226240

241+
<TouchableOpacity
242+
onPress={() => updateDisplay(callUUID)}
243+
style={styles.button}
244+
hitSlop={hitSlop}
245+
>
246+
<Text>Update display</Text>
247+
</TouchableOpacity>
248+
227249
<TouchableOpacity
228250
onPress={() => setOnMute(callUUID, !mutedCalls[callUUID])}
229251
style={styles.button}

example/ios/CallKeepDemo.xcodeproj/xcshareddata/xcschemes/CallKeepDemo.xcscheme

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0940"
3+
LastUpgradeVersion = "1030"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "NO"

example/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"react-dom": "^16.8.6",
1212
"react-native": "0.59.8",
1313
"react-native-background-timer": "^2.1.1",
14-
"react-native-callkeep": "https://github.com/react-native-webrtc/react-native-callkeep",
14+
"react-native-callkeep": "https://github.com/react-native-webrtc/react-native-callkeep#fix_outgoing_call_ios",
1515
"react-native-device-info": "^2.3.2",
1616
"react-native-gesture-handler": "~1.3.0",
1717
"react-native-reanimated": "~1.1.0",

example/yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -4132,9 +4132,9 @@ react-native-branch@~3.0.1:
41324132
resolved "https://registry.yarnpkg.com/react-native-branch/-/react-native-branch-3.0.1.tgz#5b07b61cbd290168cd3c3662e017ebe0f356d2ca"
41334133
integrity sha512-vbcYxPZlpF5f39GAEUF8kuGQqCNeD3E6zEdvtOq8oCGZunHXlWlKgAS6dgBKCvsHvXgHuMtpvs39VgOp8DaKig==
41344134

4135-
"react-native-callkeep@https://github.com/react-native-webrtc/react-native-callkeep":
4136-
version "3.0.0"
4137-
resolved "https://github.com/react-native-webrtc/react-native-callkeep#46b9a488f737a002d73327847a8d8190f171754a"
4135+
"react-native-callkeep@https://github.com/react-native-webrtc/react-native-callkeep#fix_outgoing_call_ios":
4136+
version "3.0.1"
4137+
resolved "https://github.com/react-native-webrtc/react-native-callkeep#22a3f2d9f8ede5e83f88d9a16c3786efe249ce1f"
41384138

41394139
react-native-device-info@^2.3.2:
41404140
version "2.3.2"

index.d.ts

+43-16
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ export type Events =
33
'answerCall' |
44
'endCall' |
55
'didActivateAudioSession' |
6+
'didDeactivateAudioSession' |
67
'didDisplayIncomingCall' |
8+
'didToggleHoldCallAction' |
9+
'didPerformDTMFAction' |
10+
'didResetProvider' |
711
'didPerformSetMutedCallAction';
812

913
type HandleType = 'generic' | 'number' | 'email';
@@ -12,13 +16,18 @@ interface IOptions {
1216
ios: {
1317
appName: string,
1418
imageName?: string,
19+
supportsVideo: false,
20+
maximumCallGroups: '1',
21+
maximumCallsPerCallGroup: '1'
1522
ringtoneSound?: string,
1623
},
1724
android: {
1825
alertTitle: string,
1926
alertDescription: string,
2027
cancelButton: string,
2128
okButton: string,
29+
imageName?: string,
30+
additionalPermissions: string[],
2231
},
2332
}
2433

@@ -41,6 +50,10 @@ export default class RNCallKeep {
4150

4251
}
4352

53+
static hasDefaultPhoneAccount(): boolean {
54+
55+
}
56+
4457
static displayIncomingCall(
4558
uuid: string,
4659
handle: string,
@@ -51,15 +64,19 @@ export default class RNCallKeep {
5164

5265
}
5366

54-
/**
55-
* @description startCall method is available only on iOS.
56-
*/
5767
static startCall(
5868
uuid: string,
5969
handle: string,
70+
contactIdentifier?: string,
6071
handleType?: HandleType,
6172
hasVideo?: boolean,
62-
contactIdentifier?: string,
73+
) {
74+
75+
}
76+
static updateDisplay(
77+
uuid: string,
78+
displayName: string,
79+
handle: string,
6380
) {
6481

6582
}
@@ -71,6 +88,20 @@ export default class RNCallKeep {
7188

7289
}
7390

91+
/**
92+
* @description reportConnectedOutgoingCallWithUUID method is available only on iOS.
93+
*/
94+
static reportConnectingOutgoingCallWithUUID(uuid: string): void {
95+
96+
}
97+
static reportEndCallWithUUID(uuid: string, reason: number): void {
98+
99+
}
100+
101+
static rejectCall(uuid: string) {
102+
103+
}
104+
74105
static endCall(uuid: string) {
75106

76107
}
@@ -93,30 +124,32 @@ export default class RNCallKeep {
93124

94125
}
95126

127+
static async hasOutgoingCall(): Promise<boolean> {
128+
129+
}
130+
96131
/**
97132
* @description setMutedCall method is available only on iOS.
98133
*/
99134
static setMutedCall(uuid: string, muted: boolean) {
100135

101136
}
102137

138+
static setOnHold(uuid: string, held: boolean) {
139+
140+
}
141+
103142
/**
104143
* @descriptions sendDTMF is used to send DTMF tones to the PBX.
105144
*/
106145
static sendDTMF(uuid: string, key: string) {
107146

108147
}
109148

110-
/**
111-
* @description setMutedCall method is available only on iOS.
112-
*/
113149
static checkIfBusy(): Promise<boolean> {
114150

115151
}
116152

117-
/**
118-
* @description setMutedCall method is available only on iOS.
119-
*/
120153
static checkSpeaker(): Promise<boolean> {
121154

122155
}
@@ -128,16 +161,10 @@ export default class RNCallKeep {
128161

129162
}
130163

131-
/**
132-
* @description setAvailable method is available only on Android.
133-
*/
134164
static setCurrentCallActive() {
135165

136166
}
137167

138-
/**
139-
* @description setAvailable method is available only on Android.
140-
*/
141168
static backToForeground() {
142169

143170
}

index.js

+14-21
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class RNCallKeep {
5858
if (!isIOS) {
5959
RNCallKeepModule.answerIncomingCall(uuid);
6060
}
61-
}
61+
};
6262

6363
startCall = (uuid, handle, contactIdentifier, handleType = 'number', hasVideo = false ) => {
6464
if (!isIOS) {
@@ -83,9 +83,8 @@ class RNCallKeep {
8383
}
8484
};
8585

86-
reportEndCallWithUUID = (uuid, reason) => {
86+
reportEndCallWithUUID = (uuid, reason) =>
8787
RNCallKeepModule.reportEndCallWithUUID(uuid, reason);
88-
}
8988

9089
/*
9190
* Android explicitly states we reject a call
@@ -97,15 +96,11 @@ class RNCallKeep {
9796
} else {
9897
RNCallKeepModule.endCall(uuid);
9998
}
100-
}
101-
102-
endCall = (uuid) => {
103-
RNCallKeepModule.endCall(uuid);
10499
};
105100

106-
endAllCalls = () => {
107-
RNCallKeepModule.endAllCalls();
108-
};
101+
endCall = (uuid) => RNCallKeepModule.endCall(uuid);
102+
103+
endAllCalls = () => RNCallKeepModule.endAllCalls();
109104

110105
supportConnectionService = () => supportConnectionService;
111106

@@ -119,9 +114,7 @@ class RNCallKeep {
119114
RNCallKeepModule.setMutedCall(uuid, shouldMute);
120115
};
121116

122-
sendDTMF = (uuid, key) => {
123-
RNCallKeepModule.sendDTMF(uuid, key);
124-
};
117+
sendDTMF = (uuid, key) => RNCallKeepModule.sendDTMF(uuid, key);
125118

126119
checkIfBusy = () =>
127120
isIOS
@@ -150,18 +143,18 @@ class RNCallKeep {
150143
RNCallKeepModule.setCurrentCallActive(callUUID);
151144
};
152145

153-
updateDisplay = (uuid, displayName, uri) => {
154-
RNCallKeepModule.updateDisplay(uuid, displayName, uri)
155-
}
146+
updateDisplay = (uuid, displayName, handle) => RNCallKeepModule.updateDisplay(uuid, displayName, handle);
156147

157-
setOnHold = (uuid, shouldHold) => {
158-
RNCallKeepModule.setOnHold(uuid, shouldHold);
159-
}
148+
setOnHold = (uuid, shouldHold) => RNCallKeepModule.setOnHold(uuid, shouldHold);
160149

161-
reportUpdatedCall = (uuid, localizedCallerName) =>
162-
isIOS
150+
// @deprecated
151+
reportUpdatedCall = (uuid, localizedCallerName) => {
152+
console.warn('RNCallKeep.reportUpdatedCall is deprecarted, use RNCallKeep.updateDisplay instead');
153+
154+
return isIOS
163155
? RNCallKeepModule.reportUpdatedCall(uuid, localizedCallerName)
164156
: Promise.reject('RNCallKeep.reportUpdatedCall was called from unsupported OS');
157+
};
165158

166159
_setupIOS = async (options) => new Promise((resolve, reject) => {
167160
if (!options.appName) {

ios/RNCallKeep/RNCallKeep.m

+1
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ - (void)provider:(CXProvider *)provider performStartCallAction:(CXStartCallActio
500500
}
501501

502502
// Update call contact info
503+
// @deprecated
503504
RCT_EXPORT_METHOD(reportUpdatedCall:(NSString *)uuidString contactIdentifier:(NSString *)contactIdentifier)
504505
{
505506
#ifdef DEBUG

0 commit comments

Comments
 (0)