Skip to content

Commit

Permalink
ios: implemet support options for updateDisplay
Browse files Browse the repository at this point in the history
  • Loading branch information
zxcpoiu committed Nov 12, 2020
1 parent ae3830d commit 07afe95
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ declare module 'react-native-callkeep' {
uuid: string,
displayName: string,
handle: string,
options?: object,
): void

static checkPhoneAccountEnabled(): Promise<boolean>;
Expand Down
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,17 @@ class RNCallKeep {
RNCallKeepModule.setCurrentCallActive(callUUID);
};

updateDisplay = (uuid, displayName, handle) => RNCallKeepModule.updateDisplay(uuid, displayName, handle);
updateDisplay = (uuid, displayName, handle, options = null) => {
if (!isIOS) {
RNCallKeepModule.updateDisplay(uuid, displayName, handle);
return;
}

if (!options) {
options = {};
}
RNCallKeepModule.updateDisplay(uuid, displayName, handle, options);
};

setOnHold = (uuid, shouldHold) => RNCallKeepModule.setOnHold(uuid, shouldHold);

Expand Down
19 changes: 18 additions & 1 deletion ios/RNCallKeep/RNCallKeep.m
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ + (void)initCallKitProvider {
[RNCallKeep endCallWithUUID: uuidString reason:reason];
}

RCT_EXPORT_METHOD(updateDisplay:(NSString *)uuidString :(NSString *)displayName :(NSString *)uri)
RCT_EXPORT_METHOD(updateDisplay:(NSString *)uuidString :(NSString *)displayName :(NSString *)uri :(NSDictionary *)options)
{
#ifdef DEBUG
NSLog(@"[RNCallKeep][updateDisplay] uuidString = %@ displayName = %@ uri = %@", uuidString, displayName, uri);
Expand All @@ -289,6 +289,23 @@ + (void)initCallKitProvider {
CXCallUpdate *callUpdate = [[CXCallUpdate alloc] init];
callUpdate.localizedCallerName = displayName;
callUpdate.remoteHandle = callHandle;

if ([options valueForKey:@"hasVideo"] != nil) {
callUpdate.hasVideo = [RCTConvert BOOL:options[@"hasVideo"]];
}
if ([options valueForKey:@"supportsHolding"] != nil) {
callUpdate.supportsHolding = [RCTConvert BOOL:options[@"supportsHolding"]];
}
if ([options valueForKey:@"supportsDTMF"] != nil) {
callUpdate.supportsDTMF = [RCTConvert BOOL:options[@"supportsDTMF"]];
}
if ([options valueForKey:@"supportsGrouping"] != nil) {
callUpdate.supportsGrouping = [RCTConvert BOOL:options[@"supportsGrouping"]];
}
if ([options valueForKey:@"supportsUngrouping"] != nil) {
callUpdate.supportsUngrouping = [RCTConvert BOOL:options[@"supportsUngrouping"]];
}

[self.callKeepProvider reportCallWithUUID:uuid updated:callUpdate];
}

Expand Down

0 comments on commit 07afe95

Please sign in to comment.