fix(ios) fix conference failing when proximity sensor is near

React Native links timers to the display, so they cannot run when the display is
not running. Builtin timers already take being in the background into account,
but not the proximity sensor.

Credits: https://github.com/react-native-webrtc/react-native-callkeep/issues/143

Fixes: https://github.com/jitsi/jitsi-meet/issues/9619
This commit is contained in:
Saúl Ibarra Corretgé 2021-08-19 13:23:06 +02:00 committed by Saúl Ibarra Corretgé
parent 27e4e862fd
commit 10cc3b2b31
1 changed files with 33 additions and 0 deletions

View File

@ -11,6 +11,39 @@ index bd48f44..d243ed0 100644
withDispatchGroup:(dispatch_group_t)dispatchGroup withDispatchGroup:(dispatch_group_t)dispatchGroup
lazilyDiscovered:(BOOL)lazilyDiscovered lazilyDiscovered:(BOOL)lazilyDiscovered
{ {
diff --git a/node_modules/react-native/React/Modules/RCTTiming.m b/node_modules/react-native/React/Modules/RCTTiming.m
index 8a09022..265d7b6 100644
--- a/node_modules/react-native/React/Modules/RCTTiming.m
+++ b/node_modules/react-native/React/Modules/RCTTiming.m
@@ -130,6 +130,11 @@ - (void)setBridge:(RCTBridge *)bridge
object:nil];
}
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(proximityChanged)
+ name:UIDeviceProximityStateDidChangeNotification
+ object:nil];
+
_bridge = bridge;
}
@@ -276,6 +281,16 @@ - (void)didUpdateFrame:(RCTFrameUpdate *)update
}
}
+-(void)proximityChanged
+{
+ BOOL near = [UIDevice currentDevice].proximityState;
+ if (near) {
+ [self appDidMoveToBackground];
+ } else {
+ [self appDidMoveToForeground];
+ }
+}
+
- (void)scheduleSleepTimer:(NSDate *)sleepTarget
{
@synchronized (self) {
diff --git a/node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm b/node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm diff --git a/node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm b/node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm
index 3cb73b5..e4a14b4 100644 index 3cb73b5..e4a14b4 100644
--- a/node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm --- a/node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm