Skip to content

Commit 9a1a518

Browse files
authored
Merge pull request react-native-webrtc#60 from TeamGuilded/chevonc/updateCallMethod
Fix react-native-webrtc#54 and ReportUpdatedCall API
2 parents 5cae457 + 8778487 commit 9a1a518

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ class RNCallKeep {
9090
};
9191

9292
checkIfBusy = () =>
93-
Platform.OS === 'ios'
93+
isIOS
9494
? RNCallKeepModule.checkIfBusy()
9595
: Promise.reject('RNCallKeep.checkIfBusy was called from unsupported OS');
9696

9797
checkSpeaker = () =>
98-
Platform.OS === 'ios'
98+
isIOS
9999
? RNCallKeepModule.checkSpeaker()
100100
: Promise.reject('RNCallKeep.checkSpeaker was called from unsupported OS');
101101

@@ -116,6 +116,11 @@ class RNCallKeep {
116116
RNCallKeepModule.setCurrentCallActive();
117117
};
118118

119+
reportUpdatedCall = (uuid, localizedCallerName) =>
120+
isIOS
121+
? RNCallKeepModule.reportUpdatedCall(uuid, localizedCallerName)
122+
: Promise.reject('RNCallKeep.reportUpdatedCall was called from unsupported OS');
123+
119124
_setupIOS = async (options) => new Promise((resolve, reject) => {
120125
if (!options.appName) {
121126
reject('RNCallKeep.setup: option "appName" is required');

ios/RNCallKeep/RNCallKeep.m

+16-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ - (void)dealloc
132132
callUpdate.supportsHolding = YES;
133133
callUpdate.supportsGrouping = YES;
134134
callUpdate.supportsUngrouping = YES;
135-
callUpdate.hasVideo = NO;
135+
callUpdate.hasVideo = hasVideo;
136136
callUpdate.localizedCallerName = localizedCallerName;
137137

138138
[self.callKeepProvider reportNewIncomingCallWithUUID:uuid update:callUpdate completion:^(NSError * _Nullable error) {
@@ -247,11 +247,12 @@ - (void)requestTransaction:(CXTransaction *)transaction
247247
CXStartCallAction *startCallAction = [transaction.actions firstObject];
248248
CXCallUpdate *callUpdate = [[CXCallUpdate alloc] init];
249249
callUpdate.remoteHandle = startCallAction.handle;
250+
callUpdate.hasVideo = startCallAction.video;
251+
callUpdate.localizedCallerName = startCallAction.contactIdentifier;
250252
callUpdate.supportsDTMF = YES;
251253
callUpdate.supportsHolding = YES;
252254
callUpdate.supportsGrouping = YES;
253255
callUpdate.supportsUngrouping = YES;
254-
callUpdate.hasVideo = NO;
255256
[self.callKeepProvider reportCallWithUUID:startCallAction.callUUID updated:callUpdate];
256257
}
257258
}
@@ -433,6 +434,19 @@ - (void)provider:(CXProvider *)provider performStartCallAction:(CXStartCallActio
433434
[action fulfill];
434435
}
435436

437+
// Update call contact info
438+
RCT_EXPORT_METHOD(reportUpdatedCall:(NSString *)uuidString contactIdentifier:(NSString *)contactIdentifier)
439+
{
440+
#ifdef DEBUG
441+
NSLog(@"[RNCallKeep][reportUpdatedCall] contactIdentifier = %i", contactIdentifier);
442+
#endif
443+
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString];
444+
CXCallUpdate *callUpdate = [[CXCallUpdate alloc] init];
445+
callUpdate.localizedCallerName = contactIdentifier;
446+
447+
[self.callKeepProvider reportCallWithUUID:uuid updated:callUpdate];
448+
}
449+
436450
// Answering incoming call
437451
- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action
438452
{

0 commit comments

Comments
 (0)