Skip to content

Commit ae3830d

Browse files
committed
ios: implement support options for disaply incoming call
1 parent 3bcd5ea commit ae3830d

File tree

4 files changed

+63
-11
lines changed

4 files changed

+63
-11
lines changed

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ declare module 'react-native-callkeep' {
6161
localizedCallerName?: string,
6262
handleType?: HandleType,
6363
hasVideo?: boolean,
64+
options?: object,
6465
): void
6566

6667
static startCall(

index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,25 @@ class RNCallKeep {
7777
return;
7878
};
7979

80-
displayIncomingCall = (uuid, handle, localizedCallerName = '', handleType = 'number', hasVideo = false) => {
80+
displayIncomingCall = (uuid, handle, localizedCallerName = '', handleType = 'number', hasVideo = false, options = null) => {
8181
if (!isIOS) {
8282
RNCallKeepModule.displayIncomingCall(uuid, handle, localizedCallerName);
8383
return;
8484
}
8585

86-
RNCallKeepModule.displayIncomingCall(uuid, handle, handleType, hasVideo, localizedCallerName);
86+
let supportsHolding = true,
87+
supportsDTMF = true,
88+
supportsGrouping = true,
89+
supportsUngrouping = true;
90+
91+
if (options) {
92+
if (typeof options.supportsHolding === 'boolean') supportsHolding = options.supportsHolding;
93+
if (typeof options.supportsDTMF === 'boolean') supportsDTMF = options.supportsDTMF;
94+
if (typeof options.supportsGrouping === 'boolean') supportsGrouping = options.supportsGrouping;
95+
if (typeof options.supportsUngrouping === 'boolean') supportsUngrouping = options.supportsUngrouping;
96+
}
97+
98+
RNCallKeepModule.displayIncomingCall(uuid, handle, handleType, hasVideo, localizedCallerName, supportsHolding, supportsDTMF, supportsGrouping, supportsUngrouping);
8799
};
88100

89101
answerIncomingCall = (uuid) => {

ios/RNCallKeep/RNCallKeep.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ continueUserActivity:(NSUserActivity *)userActivity
3232
handleType:(NSString *)handleType
3333
hasVideo:(BOOL)hasVideo
3434
localizedCallerName:(NSString * _Nullable)localizedCallerName
35+
supportsHolding:(BOOL)supportsHolding
36+
supportsDTMF:(BOOL)supportsDTMF
37+
supportsGrouping:(BOOL)supportsGrouping
38+
supportsUngrouping:(BOOL)supportsUngrouping
3539
fromPushKit:(BOOL)fromPushKit
3640
payload:(NSDictionary * _Nullable)payload;
3741

@@ -49,4 +53,4 @@ continueUserActivity:(NSUserActivity *)userActivity
4953

5054
+ (BOOL)isCallActive:(NSString *)uuidString;
5155

52-
@end
56+
@end

ios/RNCallKeep/RNCallKeep.m

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,24 @@ + (void)initCallKitProvider {
179179
handle:(NSString *)handle
180180
handleType:(NSString *)handleType
181181
hasVideo:(BOOL)hasVideo
182-
localizedCallerName:(NSString * _Nullable)localizedCallerName)
183-
{
184-
[RNCallKeep reportNewIncomingCall: uuidString handle:handle handleType:handleType hasVideo:hasVideo localizedCallerName:localizedCallerName fromPushKit: NO payload:nil withCompletionHandler:nil];
182+
localizedCallerName:(NSString * _Nullable)localizedCallerName
183+
supportsHolding:(BOOL)supportsHolding
184+
supportsDTMF:(BOOL)supportsDTMF
185+
supportsGrouping:(BOOL)supportsGrouping
186+
supportsUngrouping:(BOOL)supportsUngrouping)
187+
{
188+
[RNCallKeep reportNewIncomingCall: uuidString
189+
handle: handle
190+
handleType: handleType
191+
hasVideo: hasVideo
192+
localizedCallerName: localizedCallerName
193+
supportsHolding: supportsHolding
194+
supportsDTMF: supportsDTMF
195+
supportsGrouping: supportsGrouping
196+
supportsUngrouping: supportsUngrouping
197+
fromPushKit: NO
198+
payload: nil
199+
withCompletionHandler: nil];
185200
}
186201

187202
RCT_EXPORT_METHOD(startCall:(NSString *)uuidString
@@ -390,6 +405,10 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
390405
handleType:(NSString *)handleType
391406
hasVideo:(BOOL)hasVideo
392407
localizedCallerName:(NSString * _Nullable)localizedCallerName
408+
supportsHolding:(BOOL)supportsHolding
409+
supportsDTMF:(BOOL)supportsDTMF
410+
supportsGrouping:(BOOL)supportsGrouping
411+
supportsUngrouping:(BOOL)supportsUngrouping
393412
fromPushKit:(BOOL)fromPushKit
394413
payload:(NSDictionary * _Nullable)payload
395414
{
@@ -412,10 +431,10 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
412431
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString];
413432
CXCallUpdate *callUpdate = [[CXCallUpdate alloc] init];
414433
callUpdate.remoteHandle = [[CXHandle alloc] initWithType:_handleType value:handle];
415-
callUpdate.supportsDTMF = YES;
416-
callUpdate.supportsHolding = YES;
417-
callUpdate.supportsGrouping = YES;
418-
callUpdate.supportsUngrouping = YES;
434+
callUpdate.supportsHolding = supportsHolding;
435+
callUpdate.supportsDTMF = supportsDTMF;
436+
callUpdate.supportsGrouping = supportsGrouping;
437+
callUpdate.supportsUngrouping = supportsUngrouping;
419438
callUpdate.hasVideo = hasVideo;
420439
callUpdate.localizedCallerName = localizedCallerName;
421440

@@ -428,6 +447,10 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
428447
@"handle": handle,
429448
@"localizedCallerName": localizedCallerName ? localizedCallerName : @"",
430449
@"hasVideo": hasVideo ? @"1" : @"0",
450+
@"supportsHolding": supportsHolding ? @"1" : @"0",
451+
@"supportsDTMF": supportsDTMF ? @"1" : @"0",
452+
@"supportsGrouping": supportsGrouping ? @"1" : @"0",
453+
@"supportsUngrouping": supportsUngrouping ? @"1" : @"0",
431454
@"fromPushKit": fromPushKit ? @"1" : @"0",
432455
@"payload": payload ? payload : @"",
433456
}];
@@ -443,14 +466,26 @@ + (void)reportNewIncomingCall:(NSString *)uuidString
443466
}];
444467
}
445468

469+
// --- overloading functions for backward compatibility and simple api
446470
+ (void)reportNewIncomingCall:(NSString *)uuidString
447471
handle:(NSString *)handle
448472
handleType:(NSString *)handleType
449473
hasVideo:(BOOL)hasVideo
450474
localizedCallerName:(NSString * _Nullable)localizedCallerName
451475
fromPushKit:(BOOL)fromPushKit
452476
{
453-
[RNCallKeep reportNewIncomingCall: uuidString handle:handle handleType:handleType hasVideo:hasVideo localizedCallerName:localizedCallerName fromPushKit: fromPushKit payload:nil withCompletionHandler:nil];
477+
[RNCallKeep reportNewIncomingCall: uuidString
478+
handle: handle
479+
handleType: handleType
480+
hasVideo: hasVideo
481+
localizedCallerName: localizedCallerName
482+
supportsHolding: YES
483+
supportsDTMF: YES
484+
supportsGrouping: YES
485+
supportsUngrouping: YES
486+
fromPushKit: fromPushKit
487+
payload: nil
488+
withCompletionHandler: nil];
454489
}
455490

456491
- (BOOL)lessThanIos10_2

0 commit comments

Comments
 (0)