Created
July 6, 2022 09:30
-
-
Save Hesowcharov/1e3e0dcdc6806fb0b234f01d7d9233a6 to your computer and use it in GitHub Desktop.
react-native-callkeep: fulfill end call actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/index.d.ts b/index.d.ts | |
index dd24741..855f018 100644 | |
--- a/index.d.ts | |
+++ b/index.d.ts | |
@@ -134,6 +134,8 @@ declare module 'react-native-callkeep' { | |
static endCall(uuid: string): void | |
+ static fulfillEndCall(uuid: string): void | |
+ | |
static endAllCalls(): void | |
static setReachable(): void | |
diff --git a/index.js b/index.js | |
index 3b70ad7..8fa2bf3 100644 | |
--- a/index.js | |
+++ b/index.js | |
@@ -178,6 +178,12 @@ class RNCallKeep { | |
endCall = (uuid) => RNCallKeepModule.endCall(uuid); | |
+ fulfillEndCall = (uuid) => { | |
+ if (isIOS) { | |
+ RNCallKeepModule.fulfillEndCall(uuid); | |
+ } | |
+ }; | |
+ | |
endAllCalls = () => RNCallKeepModule.endAllCalls(); | |
supportConnectionService = () => supportConnectionService; | |
diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m | |
index 802b7a0..8524093 100644 | |
--- a/ios/RNCallKeep/RNCallKeep.m | |
+++ b/ios/RNCallKeep/RNCallKeep.m | |
@@ -45,6 +45,7 @@ static NSString *const RNCallKeepDidLoadWithEvents = @"RNCallKeepDidLoadWithEven | |
bool _hasListeners; | |
bool _isReachable; | |
NSMutableArray *_delayedEvents; | |
+ NSMutableDictionary<NSString*, CXEndCallAction*> *_endCallActions; | |
} | |
static bool isSetupNatively; | |
@@ -63,6 +64,7 @@ RCT_EXPORT_MODULE() | |
_isStartCallActionEventListenerAdded = NO; | |
_isReachable = NO; | |
if (_delayedEvents == nil) _delayedEvents = [NSMutableArray array]; | |
+ if (_endCallActions == nil) _endCallActions = [[NSMutableDictionary alloc] init]; | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(onAudioRouteChange:) | |
@@ -99,6 +101,7 @@ RCT_EXPORT_MODULE() | |
} | |
sharedProvider = nil; | |
_isReachable = NO; | |
+ _endCallActions = nil; | |
handleToUuidDict = nil; | |
} | |
@@ -360,6 +363,19 @@ RCT_EXPORT_METHOD(endCall:(NSString *)uuidString) | |
[self requestTransaction:transaction]; | |
} | |
+RCT_EXPORT_METHOD(fulfillEndCall:(NSString *)uuidString) | |
+{ | |
+#ifdef DEBUG | |
+ NSLog(@"[RNCallKeep][fulfillEndCall] uuidString = %@", uuidString); | |
+#endif | |
+ CXCallAction* action = [_endCallActions valueForKey:uuidString]; | |
+ if (action) { | |
+ NSLog(@"[RNCallKeep][fulfillEndCall] fulfilling the end call action"); | |
+ [action fulfill]; | |
+ [_endCallActions removeObjectForKey:uuidString]; | |
+ }; | |
+} | |
+ | |
RCT_EXPORT_METHOD(endAllCalls) | |
{ | |
#ifdef DEBUG | |
@@ -1077,7 +1093,8 @@ RCT_EXPORT_METHOD(reportUpdatedCall:(NSString *)uuidString contactIdentifier:(NS | |
} | |
} | |
[self sendEventWithNameWrapper:RNCallKeepPerformEndCallAction body:@{ @"callUUID": [action.callUUID.UUIDString lowercaseString] }]; | |
- [action fulfill]; | |
+ [_endCallActions setValue:action forKey: [action.callUUID.UUIDString lowercaseString]]; | |
+ // TODO: consider auto-fulfillment | |
} | |
-(void)provider:(CXProvider *)provider performSetHeldCallAction:(CXSetHeldCallAction *)action |
Hey! Actually I don't remember exactly, but it should be around the moment when you intent to end the call in the operation system. So, the method starts working only after the call has been started
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hey man, where do you call
fulfillEndCall(uuid: string)
in the js side?