## Application Delegate

APNs requires an application delegate to handle push notifications functionality via delegate methods. If your app does not already have an application delegate, you will need to create one:

1. Create a class that subclasses `NSObject` and implements the `UIApplicationDelegate` (iOS/tvOS), `WKApplicationDelegate` (watchOS), or `NSApplicationDelegate` (macOS) protocol.

<BlockSwitcher>
<Block name="iOS/tvOS">

```swift
class AppDelegate: NSObject, UIApplicationDelegate {

}
```

</Block>
<Block name="macOS">

```swift
class AppDelegate: NSObject, NSApplicationDelegate {

}
```

</Block>
<Block name="watchOS">

```swift
class AppDelegate: NSObject, WKApplicationDelegate {

}
```

</Block>
</BlockSwitcher>

2. Add a property to your main app struct that identifies your application delegate.

<BlockSwitcher>
<Block name="iOS/tvOS">

```swift
@main
struct <YOUR_APP_NAME>App: App {
    @UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
    // ...
}
```

</Block>
<Block name="macOS">

```swift
@main
struct <YOUR_APP_NAME>App: App {
    @NSApplicationDelegateAdaptor private var appDelegate: AppDelegate
    // ...
}
```

</Block>
<Block name="watchOS">

```swift
@main
struct <YOUR_APP_NAME>App: App {
    @WKApplicationDelegateAdaptor private var appDelegate: AppDelegate
    // ...
}
```

</Block>
</BlockSwitcher>
