Instance Method

setTaskCompletedWithSnapshot:

Marks the task as complete and indicates whether the system should take a new snapshot of the app.

Declaration

- (void)setTaskCompletedWithSnapshot:(BOOL)refreshSnapshot;

Parameters

refreshSnapshot

A Boolean value that indicates whether the system should take a new snapshot of the app.

Discussion

Call this method as soon as a nonsnapshot background task (any WKRefreshBackgroundTask subclass except the WKSnapshotRefreshBackgroundTask class) is complete.

To update the app's snapshot in response to the current task, pass YES, and the system schedules an immediate snapshot. This request counts against the standard snapshot budget and overwrites any requests made using the scheduleSnapshotRefreshWithPreferredDate:userInfo:scheduledCompletion: method. As with all snapshots, your app receives a WKSnapshotRefreshBackgroundTask before the snapshot is taken.

The system provides your extension with a limited amount of time (on the order of seconds) to finish this task. If you do not call setTaskCompletedWithSnapshot: on the task, the system continues to run in the background until all available time is consumed, wasting battery power.

The system suspends the extension as soon as all background tasks are complete.

When completing a snapshot background task, you generally call the setTaskCompletedWithDefaultStateRestored:estimatedSnapshotExpiration:userInfo:method and explicitly set the date for the next snapshot. You can call setTaskCompletedWithSnapshot: as a simpler alternative. If you pass YES, the system schedules a new snapshot task in one hour. If you pass NO, no snapshot is scheduled.

See Also

Completing the Background Task

- setTaskCompleted

Marks the task as complete.

Deprecated