@@ -97,7 +97,6 @@ @implementation RCTTiming
9797 NSTimer *_sleepTimer;
9898 BOOL _sendIdleEvents;
9999 BOOL _inBackground;
100- UIBackgroundTaskIdentifier _backgroundTaskIdentifier;
101100}
102101
103102@synthesize bridge = _bridge;
@@ -113,7 +112,6 @@ - (void)setBridge:(RCTBridge *)bridge
113112 _paused = YES ;
114113 _timers = [NSMutableDictionary new ];
115114 _inBackground = NO ;
116- _backgroundTaskIdentifier = UIBackgroundTaskInvalid;
117115
118116 for (NSString *name in @[UIApplicationWillResignActiveNotification,
119117 UIApplicationDidEnterBackgroundNotification,
@@ -137,35 +135,10 @@ - (void)setBridge:(RCTBridge *)bridge
137135
138136- (void )dealloc
139137{
140- [self markEndOfBackgroundTaskIfNeeded ];
141138 [_sleepTimer invalidate ];
142139 [[NSNotificationCenter defaultCenter ] removeObserver: self ];
143140}
144141
145- - (void )markStartOfBackgroundTaskIfNeeded
146- {
147- if (_backgroundTaskIdentifier == UIBackgroundTaskInvalid) {
148- __weak typeof (self) weakSelf = self;
149- // Marks the beginning of a new long-running background task. We can run the timer in the background.
150- _backgroundTaskIdentifier = [[UIApplication sharedApplication ] beginBackgroundTaskWithName: @" rct.timing.gb.task" expirationHandler: ^{
151- typeof (self) strongSelf = weakSelf;
152- if (!strongSelf) {
153- return ;
154- }
155- // Mark the end of background task
156- [strongSelf markEndOfBackgroundTaskIfNeeded ];
157- }];
158- }
159- }
160-
161- - (void )markEndOfBackgroundTaskIfNeeded
162- {
163- if (_backgroundTaskIdentifier != UIBackgroundTaskInvalid) {
164- [[UIApplication sharedApplication ] endBackgroundTask: _backgroundTaskIdentifier];
165- _backgroundTaskIdentifier = UIBackgroundTaskInvalid;
166- }
167- }
168-
169142- (dispatch_queue_t )methodQueue
170143{
171144 return RCTJSThread;
@@ -190,7 +163,6 @@ - (void)appDidMoveToBackground
190163
191164- (void )appDidMoveToForeground
192165{
193- [self markEndOfBackgroundTaskIfNeeded ];
194166 _inBackground = NO ;
195167 [self startTimers ];
196168}
@@ -288,7 +260,6 @@ - (void)didUpdateFrame:(RCTFrameUpdate *)update
288260 }
289261 if (_inBackground) {
290262 if (timerCount) {
291- [self markStartOfBackgroundTaskIfNeeded ];
292263 [self scheduleSleepTimer: nextScheduledTarget];
293264 }
294265 } else if (!_sendIdleEvents && timersToCall.count == 0 ) {
@@ -367,7 +338,6 @@ - (void)timerDidFire
367338 }
368339
369340 if (_inBackground) {
370- [self markStartOfBackgroundTaskIfNeeded ];
371341 [self scheduleSleepTimer: timer.target];
372342 } else if (_paused) {
373343 if ([timer.target timeIntervalSinceNow ] > kMinimumSleepInterval ) {
0 commit comments