From beaeefb331f7ba55df804a436b23127d03a1adb7 Mon Sep 17 00:00:00 2001 From: MingHieu Date: Thu, 23 Feb 2023 17:09:50 +0700 Subject: [PATCH] fix call not open app in kill state and lock screen --- ios/RNCallKeep/RNCallKeep.m | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ios/RNCallKeep/RNCallKeep.m b/ios/RNCallKeep/RNCallKeep.m index 6e847e61..e8e46105 100644 --- a/ios/RNCallKeep/RNCallKeep.m +++ b/ios/RNCallKeep/RNCallKeep.m @@ -988,7 +988,7 @@ + (BOOL)application:(UIApplication *)application }; RNCallKeep *callKeep = [RNCallKeep allocWithZone: nil]; - [callKeep sendEventWithNameWrapper:RNCallKeepDidReceiveStartCallAction body:userInfo]; + [callKeep handleStartCallNotification: userInfo]; return YES; } return NO; @@ -999,6 +999,24 @@ + (BOOL)requiresMainQueueSetup return YES; } +- (void)handleStartCallNotification:(NSDictionary *)userInfo +{ +#ifdef DEBUG + NSLog(@"[RNCallKeep][handleStartCallNotification] userInfo = %@", userInfo); +#endif + int delayInSeconds; + if (!_isStartCallActionEventListenerAdded) { + // Workaround for when app is just launched and JS side hasn't registered to the event properly + delayInSeconds = OUTGOING_CALL_WAKEUP_DELAY; + } else { + delayInSeconds = 0; + } + dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); + dispatch_after(popTime, dispatch_get_main_queue(), ^{ + [self sendEventWithNameWrapper:RNCallKeepDidReceiveStartCallAction body:userInfo]; + }); +} + #pragma mark - CXProviderDelegate - (void)providerDidReset:(CXProvider *)provider{