From 07afe9598e8af5b62e9d437e08a4a09ad7d8eb3d Mon Sep 17 00:00:00 2001 From: zxcpoiu Date: Sat, 28 Mar 2020 20:41:59 +0800 Subject: [PATCH] ios: implemet support options for updateDisplay --- index.d.ts | 1 + index.js | 12 +++++++++++- ios/RNCallKeep/RNCallKeep.m | 19 ++++++++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 97c0f810..2090fe29 100644 --- a/index.d.ts +++ b/index.d.ts @@ -76,6 +76,7 @@ declare module 'react-native-callkeep' { uuid: string, displayName: string, handle: string, + options?: object, ): void static checkPhoneAccountEnabled(): Promise; diff --git a/index.js b/index.js index fe8235c4..7a48d174 100644 --- a/index.js +++ b/index.js @@ -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); diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index 162f102a..c1b042a6 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -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); @@ -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]; }