---
title: WKBluetoothAlertRefreshBackgroundTask
framework: watchkit
role: symbol
role_heading: Class
path: watchkit/wkbluetoothalertrefreshbackgroundtask
---

# WKBluetoothAlertRefreshBackgroundTask

A task for handling timely Bluetooth alerts in the background.

## Declaration

```swift
class WKBluetoothAlertRefreshBackgroundTask
```

## Mentioned in

Using background tasks

## Overview

Overview Your app can receive WKBluetoothAlertRefreshBackgroundTask tasks to handle timely alerts in the background. Use these tasks to reconnect a peripheral and handle a critical alert. Apps that use timely alerts can also scan for a specific system identifier (UUID) while in the background. You can then perform the initial connection and pair the devices if necessary. To receive timely alerts, your peripheral must use Generic Attribute Profile (GATT) transactions. Call setNotifyValue(_:for:) to enable notifications for the specified characteristic. Then, any changes to the peripheral’s characteristic wakes your app using a WKBluetoothAlertRefreshBackgroundTask task. Use this task to reconnect to the peripheral and handle the critical alert. note: In watchOS 9 and later, SwiftUI Background tasks are the preferred way to handle background tasks and interactions. For more information, backgroundTask(_:action:). The critical alerts and background scans share a budget. Your app can only use five timely alerts or background scans within a rolling 24-hour window. When your app receives a timely alert and your budget has only one Bluetooth alert task remaining, the system raises a leGattNearBackgroundNotificationLimit error. If you exceed the budget, it raises a leGattExceededBackgroundNotificationLimit error. The system passes these errors to your CBPeripheralDelegate, by calling methods like the peripheral(_:didUpdateValueFor:error:) method. If you exceed your budget, your app doesn’t receive any timely alerts until additional background budget becomes available. The user can reset this budget by launching your app.

## Relationships

### Inherits From

- [WKRefreshBackgroundTask](watchkit/wkrefreshbackgroundtask.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Background tasks

- [Using background tasks](watchkit/using-background-tasks.md)
- [Preparing to take your watchOS app’s snapshot](watchkit/preparing-to-take-your-watchos-app-s-snapshot.md)
- [WKApplicationRefreshBackgroundTask](watchkit/wkapplicationrefreshbackgroundtask.md)
- [WKURLSessionRefreshBackgroundTask](watchkit/wkurlsessionrefreshbackgroundtask.md)
- [WKWatchConnectivityRefreshBackgroundTask](watchkit/wkwatchconnectivityrefreshbackgroundtask.md)
- [WKIntentDidRunRefreshBackgroundTask](watchkit/wkintentdidrunrefreshbackgroundtask.md)
- [WKRelevantShortcutRefreshBackgroundTask](watchkit/wkrelevantshortcutrefreshbackgroundtask.md)
- [WKSnapshotRefreshBackgroundTask](watchkit/wksnapshotrefreshbackgroundtask.md)
- [WKRefreshBackgroundTask](watchkit/wkrefreshbackgroundtask.md)
