Skip to content

Commit dcd8511

Browse files
committed
Fix timers on proximity state change
1 parent 84b75f6 commit dcd8511

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

React/CoreModules/RCTTiming.mm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ - (void)setup
148148
name:name
149149
object:nil];
150150
}
151+
152+
[[NSNotificationCenter defaultCenter] addObserver:self
153+
selector:@selector(deviceProximityStateDidChange)
154+
name:UIDeviceProximityStateDidChangeNotification
155+
object:nil];
151156
}
152157

153158
- (void)dealloc
@@ -184,6 +189,15 @@ - (void)appDidMoveToForeground
184189
[self startTimers];
185190
}
186191

192+
- (void)deviceProximityStateDidChange
193+
{
194+
if ([[UIDevice currentDevice] proximityState]) {
195+
[self appDidMoveToBackground];
196+
} else {
197+
[self appDidMoveToForeground];
198+
}
199+
}
200+
187201
- (void)stopTimers
188202
{
189203
if (_inBackground) {

0 commit comments

Comments
 (0)