Skip to content

Commit

Permalink
feat: bg instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cdillard-NewRelic committed Jan 5, 2024
1 parent 6f17549 commit 95aeceb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Agent/General/NewRelicAgentInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ - (void) scheduleHeartbeatTask {
if (@available(iOS 13.0, *)) {
// TODO: Pass instrumented app bundle id
BGAppRefreshTaskRequest *request = [[BGAppRefreshTaskRequest alloc] initWithIdentifier:@"com.newrelic.NRApp.bitcode"];
request.earliestBeginDate = [NSDate dateWithTimeIntervalSinceNow:5 * 60];
request.earliestBeginDate = nil;//[NSDate dateWithTimeIntervalSinceNow:5 * 60];

NSError *error = nil;

Expand All @@ -806,13 +806,16 @@ - (void) handleAppRefreshTask:(BGAppRefreshTask *)task {
NRLOG_VERBOSE(@"handleAppRefreshTask BGAppRefreshTask");
if (@available(iOS 13.0, *)) {

// We always reschedule the heartbeat task.
[self scheduleHeartbeatTask];

[task setExpirationHandler:^{
__weak BGTask *weakTask = task;
if (weakTask) {
[weakTask setTaskCompletedWithSuccess:false];
}
//TODO: Invalidate and cancel the harvest request
// PokeManager.urlSession.invalidateAndCancel()
// weakTask.invalidateAndCancel()

}];

Expand All @@ -821,8 +824,6 @@ - (void) handleAppRefreshTask:(BGAppRefreshTask *)task {
// TODO: Make sure this is the right place to call this.
[task setTaskCompletedWithSuccess:true];

// We always reschedule the heartbeat task.
[self scheduleHeartbeatTask];
}
else {
NRLOG_VERBOSE(@"No background tasks pre iOS 13");
Expand Down

0 comments on commit 95aeceb

Please sign in to comment.