You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

react-native+0.68.1.patch 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. diff --git a/node_modules/react-native/React/CoreModules/RCTTiming.mm b/node_modules/react-native/React/CoreModules/RCTTiming.mm
  2. index 13d0d57..00e5d4c 100644
  3. --- a/node_modules/react-native/React/CoreModules/RCTTiming.mm
  4. +++ b/node_modules/react-native/React/CoreModules/RCTTiming.mm
  5. @@ -127,7 +127,15 @@ - (void)setup
  6. {
  7. _paused = YES;
  8. _timers = [NSMutableDictionary new];
  9. - _inBackground = NO;
  10. +
  11. + __block BOOL initialInBackground;
  12. + dispatch_sync(dispatch_get_main_queue(), ^{
  13. + initialInBackground
  14. + = [UIApplication sharedApplication].applicationState == UIApplicationStateBackground
  15. + || [UIDevice currentDevice].proximityState;
  16. + });
  17. +
  18. + _inBackground = initialInBackground;
  19. for (NSString *name in @[
  20. UIApplicationWillResignActiveNotification,
  21. @@ -146,6 +154,11 @@ - (void)setup
  22. name:name
  23. object:nil];
  24. }
  25. +
  26. + [[NSNotificationCenter defaultCenter] addObserver:self
  27. + selector:@selector(proximityChanged)
  28. + name:UIDeviceProximityStateDidChangeNotification
  29. + object:nil];
  30. }
  31. - (void)dealloc
  32. @@ -182,6 +195,16 @@ - (void)appDidMoveToForeground
  33. [self startTimers];
  34. }
  35. +- (void)proximityChanged
  36. +{
  37. + BOOL isClose = [UIDevice currentDevice].proximityState;
  38. + if (isClose) {
  39. + [self appDidMoveToBackground];
  40. + } else {
  41. + [self appDidMoveToForeground];
  42. + }
  43. +}
  44. +
  45. - (void)stopTimers
  46. {
  47. if (_inBackground) {