@@ -97,7 +97,6 @@ @implementation RCTTiming
97
97
NSTimer *_sleepTimer;
98
98
BOOL _sendIdleEvents;
99
99
BOOL _inBackground;
100
- UIBackgroundTaskIdentifier _backgroundTaskIdentifier;
101
100
}
102
101
103
102
@synthesize bridge = _bridge;
@@ -113,7 +112,6 @@ - (void)setBridge:(RCTBridge *)bridge
113
112
_paused = YES ;
114
113
_timers = [NSMutableDictionary new ];
115
114
_inBackground = NO ;
116
- _backgroundTaskIdentifier = UIBackgroundTaskInvalid;
117
115
118
116
for (NSString *name in @[UIApplicationWillResignActiveNotification,
119
117
UIApplicationDidEnterBackgroundNotification,
@@ -137,35 +135,10 @@ - (void)setBridge:(RCTBridge *)bridge
137
135
138
136
- (void )dealloc
139
137
{
140
- [self markEndOfBackgroundTaskIfNeeded ];
141
138
[_sleepTimer invalidate ];
142
139
[[NSNotificationCenter defaultCenter ] removeObserver: self ];
143
140
}
144
141
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
-
169
142
- (dispatch_queue_t )methodQueue
170
143
{
171
144
return RCTJSThread;
@@ -190,7 +163,6 @@ - (void)appDidMoveToBackground
190
163
191
164
- (void )appDidMoveToForeground
192
165
{
193
- [self markEndOfBackgroundTaskIfNeeded ];
194
166
_inBackground = NO ;
195
167
[self startTimers ];
196
168
}
@@ -288,7 +260,6 @@ - (void)didUpdateFrame:(RCTFrameUpdate *)update
288
260
}
289
261
if (_inBackground) {
290
262
if (timerCount) {
291
- [self markStartOfBackgroundTaskIfNeeded ];
292
263
[self scheduleSleepTimer: nextScheduledTarget];
293
264
}
294
265
} else if (!_sendIdleEvents && timersToCall.count == 0 ) {
@@ -367,7 +338,6 @@ - (void)timerDidFire
367
338
}
368
339
369
340
if (_inBackground) {
370
- [self markStartOfBackgroundTaskIfNeeded ];
371
341
[self scheduleSleepTimer: timer.target];
372
342
} else if (_paused) {
373
343
if ([timer.target timeIntervalSinceNow ] > kMinimumSleepInterval ) {
0 commit comments