From 460a14f8a6ec0979600f065159b4302bfc49842d Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Sun, 22 Mar 2020 03:41:32 -0400 Subject: [PATCH 01/15] checkIfActiveCall --- ios/RNCallKeep/RNCallKeep.h | 4 +++- ios/RNCallKeep/RNCallKeep.m | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ios/RNCallKeep/RNCallKeep.h b/ios/RNCallKeep/RNCallKeep.h index 4447a780..cf175b33 100644 --- a/ios/RNCallKeep/RNCallKeep.h +++ b/ios/RNCallKeep/RNCallKeep.h @@ -15,7 +15,6 @@ #import @interface RNCallKeep : RCTEventEmitter - @property (nonatomic, strong) CXCallController *callKeepCallController; @property (nonatomic, strong) CXProvider *callKeepProvider; @@ -37,4 +36,7 @@ continueUserActivity:(NSUserActivity *)userActivity + (void)endCallWithUUID:(NSString *)uuidString reason:(int)reason; + ++ (BOOL)checkIfActiveCall:(NSString *)uuidString; + @end \ No newline at end of file diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index 2fff367a..2e625612 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -304,6 +304,20 @@ - (void)requestTransaction:(CXTransaction *)transaction }]; } ++ (BOOL)checkIfActiveCall:(NSString *)uuidString +{ + CXCallObserver *callObserver = [[CXCallObserver alloc] init]; + NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString]; + + for(CXCall *call in callObserver.calls){ + NSLog(@"Connected: %d", [call.UUID isEqual:uuid]); + if([call.UUID isEqual:[[NSUUID alloc] initWithUUIDString:uuidString]] && !call.hasConnected){ + return true; + } + } + return false; +} + + (void)endCallWithUUID:(NSString *)uuidString reason:(int)reason { From a4a33e1b6fcf204fcfd28fa4acdd279ffd0261c0 Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Sun, 22 Mar 2020 03:54:17 -0400 Subject: [PATCH 02/15] Minor change --- ios/RNCallKeep/RNCallKeep.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ios/RNCallKeep/RNCallKeep.h b/ios/RNCallKeep/RNCallKeep.h index cf175b33..e0a1313f 100644 --- a/ios/RNCallKeep/RNCallKeep.h +++ b/ios/RNCallKeep/RNCallKeep.h @@ -15,6 +15,7 @@ #import @interface RNCallKeep : RCTEventEmitter + @property (nonatomic, strong) CXCallController *callKeepCallController; @property (nonatomic, strong) CXProvider *callKeepProvider; From 5286fee75bc745d77e568a420864545dae84a64b Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Sat, 4 Apr 2020 03:13:19 -0400 Subject: [PATCH 03/15] Updated with requested changes --- README.md | 15 +++++++++++++++ ios/RNCallKeep/RNCallKeep.m | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7ab81672..0829fb05 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,21 @@ Be sure to set this only after your call is ready for two way audio; used both i RNCallKeep.setCurrentCallActive(uuid); ``` +- `uuid`: string + - The `uuid` used for `startCall` or `displayIncomingCall` + +### isCallActive +_This feature is available only on IOS._ + +Returns true if the UUID passed matches an existing and answered call. +This will return true ONLY if the call exists and the user has already answered the call. It will return false +if the call does not exist or has not been answered. This is exposed to both React Native and Native sides. +This was exposed so a call can be canceled if ringing and the user answered on a different device. + +```js +RNCallKeep.isCallActive(uuid); +``` + - `uuid`: string - The `uuid` used for `startCall` or `displayIncomingCall` diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index 2e625612..c166eaf6 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -304,13 +304,13 @@ - (void)requestTransaction:(CXTransaction *)transaction }]; } -+ (BOOL)checkIfActiveCall:(NSString *)uuidString ++ (BOOL)isCallActive:(NSString *)uuidString { CXCallObserver *callObserver = [[CXCallObserver alloc] init]; NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString]; for(CXCall *call in callObserver.calls){ - NSLog(@"Connected: %d", [call.UUID isEqual:uuid]); + NSLog(@"[RNCallKeep] isCallActive %@ %d ?", call.UUID, [call.UUID isEqual:uuid]); if([call.UUID isEqual:[[NSUUID alloc] initWithUUIDString:uuidString]] && !call.hasConnected){ return true; } From 9df84d834f91aed92e37c3d666851eda6c290664 Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Wed, 8 Apr 2020 16:14:40 -0400 Subject: [PATCH 04/15] Forgot to update RNCallKeep.h to reflect rename --- ios/RNCallKeep/RNCallKeep.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/RNCallKeep/RNCallKeep.h b/ios/RNCallKeep/RNCallKeep.h index e0a1313f..9d7cba27 100644 --- a/ios/RNCallKeep/RNCallKeep.h +++ b/ios/RNCallKeep/RNCallKeep.h @@ -38,6 +38,6 @@ continueUserActivity:(NSUserActivity *)userActivity + (void)endCallWithUUID:(NSString *)uuidString reason:(int)reason; -+ (BOOL)checkIfActiveCall:(NSString *)uuidString; ++ (BOOL)isCallActive:(NSString *)uuidString; @end \ No newline at end of file From f043034775448104d211eeee93550f3143c14d25 Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Thu, 30 Apr 2020 04:24:34 -0400 Subject: [PATCH 05/15] Exposed to JS --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 37e6a559..8c770c03 100644 --- a/index.js +++ b/index.js @@ -56,6 +56,10 @@ class RNCallKeep { return; }; + isCallActive = (uuid) => { + return RNCallKeepModule.isCallActive(uuid); + } + displayIncomingCall = (uuid, handle, localizedCallerName, handleType = 'number', hasVideo = false) => { if (!isIOS) { RNCallKeepModule.displayIncomingCall(uuid, handle, localizedCallerName); From dde9e3f6ca2a9243e37510ffb786584c959ad247 Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Thu, 30 Apr 2020 04:30:28 -0400 Subject: [PATCH 06/15] Updated TS --- index.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.d.ts b/index.d.ts index 9d941a34..91b4a4fd 100644 --- a/index.d.ts +++ b/index.d.ts @@ -82,6 +82,13 @@ export default class RNCallKeep { } + // @ts-ignore + static isCallActive( + uuid: string, + ){ + + } + /** * @description reportConnectedOutgoingCallWithUUID method is available only on iOS. */ From 46fe05e775c7739ef4df41591dfc54adcc38f531 Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Thu, 30 Apr 2020 04:30:46 -0400 Subject: [PATCH 07/15] Updated TS .... again --- index.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 91b4a4fd..ec3818ec 100644 --- a/index.d.ts +++ b/index.d.ts @@ -81,9 +81,7 @@ export default class RNCallKeep { ) { } - - // @ts-ignore - static isCallActive( + static isCallActive( uuid: string, ){ From dd6e0b51eab061e32851d432d6b6501a5fabf048 Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Thu, 30 Apr 2020 04:33:35 -0400 Subject: [PATCH 08/15] More TS, new to TS in general --- index.d.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index ec3818ec..2b107622 100644 --- a/index.d.ts +++ b/index.d.ts @@ -80,11 +80,6 @@ export default class RNCallKeep { handle: string, ) { - } - static isCallActive( - uuid: string, - ){ - } /** @@ -119,7 +114,9 @@ export default class RNCallKeep { static setReachable() { } + static isCallActive(uuid: string): void{ + } /** * @description supportConnectionService method is available only on Android. */ From 15e92592b76d83d58fcddfc8a0548b310c9049bc Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Thu, 30 Apr 2020 04:40:01 -0400 Subject: [PATCH 09/15] Still new to new additions --- index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 8c770c03..1f480201 100644 --- a/index.js +++ b/index.js @@ -56,10 +56,6 @@ class RNCallKeep { return; }; - isCallActive = (uuid) => { - return RNCallKeepModule.isCallActive(uuid); - } - displayIncomingCall = (uuid, handle, localizedCallerName, handleType = 'number', hasVideo = false) => { if (!isIOS) { RNCallKeepModule.displayIncomingCall(uuid, handle, localizedCallerName); @@ -112,6 +108,8 @@ class RNCallKeep { } }; + isCallActive = (uuid) => RNCallKeepModule.isCallActive(uuid); + endCall = (uuid) => RNCallKeepModule.endCall(uuid); endAllCalls = () => RNCallKeepModule.endAllCalls(); From 00ef852c1cbb4ea1a7539128257ba05df84c35e9 Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Thu, 30 Apr 2020 04:44:50 -0400 Subject: [PATCH 10/15] Updated to properly expose to RCT EXPORT METHOD, please forgive the commits this is my first time doing this --- ios/RNCallKeep/RNCallKeep.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index a7aaeca3..ff4ed08a 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -273,6 +273,15 @@ + (void)initCallKitProvider { [self requestTransaction:transaction]; } +RCT_EXPORT_METHOD(isCallActive:(NSString *)uuidString) +{ +#ifdef DEBUG + NSLog(@"[RNCallKeep][sendDTMF] key = %@", key); +#endif + NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString]; + [RNCallKeep isCallActive: uuidString] +} + - (void)requestTransaction:(CXTransaction *)transaction { #ifdef DEBUG From 5ee1e4ac2d9d371df095b18882a4973f8f23eb86 Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Thu, 30 Apr 2020 04:46:58 -0400 Subject: [PATCH 11/15] Updated to properly expose to RCT EXPORT METHOD, please forgive the commits this is my first time doing this --- ios/RNCallKeep/RNCallKeep.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index ff4ed08a..23352016 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -276,10 +276,10 @@ + (void)initCallKitProvider { RCT_EXPORT_METHOD(isCallActive:(NSString *)uuidString) { #ifdef DEBUG - NSLog(@"[RNCallKeep][sendDTMF] key = %@", key); + NSLog(@"[RNCallKeep][isCallActive] uuid = %@", uuidString); #endif NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString]; - [RNCallKeep isCallActive: uuidString] + [RNCallKeep isCallActive: uuidString]; } - (void)requestTransaction:(CXTransaction *)transaction From 540a7c315ac18a577cf7d26d62df6fd0fc0bf624 Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Thu, 30 Apr 2020 04:49:01 -0400 Subject: [PATCH 12/15] Using proper variable >_> --- ios/RNCallKeep/RNCallKeep.m | 1 - 1 file changed, 1 deletion(-) diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index 23352016..a12791ed 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -278,7 +278,6 @@ + (void)initCallKitProvider { #ifdef DEBUG NSLog(@"[RNCallKeep][isCallActive] uuid = %@", uuidString); #endif - NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString]; [RNCallKeep isCallActive: uuidString]; } From 4fb7d0879c5e995732324b04c4858b3b86c9076c Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Thu, 30 Apr 2020 04:56:28 -0400 Subject: [PATCH 13/15] Using proper variable >_> --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 1f480201..71002ece 100644 --- a/index.js +++ b/index.js @@ -108,7 +108,7 @@ class RNCallKeep { } }; - isCallActive = (uuid) => RNCallKeepModule.isCallActive(uuid); + isCallActive = async(uuid) => RNCallKeepModule.isCallActive(uuid); endCall = (uuid) => RNCallKeepModule.endCall(uuid); From 56b6f3b1db95947856c90a4c4cc652d2b0f5e1ba Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Thu, 30 Apr 2020 04:57:12 -0400 Subject: [PATCH 14/15] Using proper variable >_> --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 71002ece..600a74cc 100644 --- a/index.js +++ b/index.js @@ -108,7 +108,7 @@ class RNCallKeep { } }; - isCallActive = async(uuid) => RNCallKeepModule.isCallActive(uuid); + isCallActive = async(uuid) => await RNCallKeepModule.isCallActive(uuid); endCall = (uuid) => RNCallKeepModule.endCall(uuid); From 095a34cb1eb57d53f22e98a3e327098e102bf0de Mon Sep 17 00:00:00 2001 From: Andre Nozari Date: Thu, 30 Apr 2020 04:58:54 -0400 Subject: [PATCH 15/15] Using proper variable >_> --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 2b107622..14f532ff 100644 --- a/index.d.ts +++ b/index.d.ts @@ -114,7 +114,7 @@ export default class RNCallKeep { static setReachable() { } - static isCallActive(uuid: string): void{ + static isCallActive(uuid: string): Promise { } /**