---
metadata:
  - name: generator
    content: Diplodoc Platform v5.64.0
alternate:
  - https://boost.yandex.com/doc/en/analytics/content/sdk/ios/push/swift/UserNotificationCenterHandling.md
  - https://boost.yandex.com/doc/ru/analytics/content/sdk/ios/push/swift/UserNotificationCenterHandling.md
  - https://boost.yandex.com/doc/zh/analytics/content/sdk/ios/push/swift/UserNotificationCenterHandling.md
  - href: https://boost.yandex.com/doc/zh/analytics/content/sdk/ios/push/swift/UserNotificationCenterHandling.md
    type: text/markdown
    title: Markdown version
  - href: https://boost.yandex.com/doc/zh/llms.txt?revision=r21738064
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://boost.yandex.com/doc/zh/llms.txt?revision=r21738064

# UserNotificationCenterHandling 协议

用于手动处理 iOS 10 及更高版本前台推送通知的代理。

使用此代理，如果您用自定义逻辑实现了[UNUserNotificationCenterDelegate](https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate?language=swift)协议。 您需要实现所有 `UNUserNotificationCenterDelegate` 的方法，并在 `UserNotificationCenterHandling` 中调用相应的方法。

该代理由 [userNotificationCenterDelegate](https://boost.yandex.com/doc/zh/analytics/content/sdk/ios/push/swift/AppMetricaPush.md#method_userNotificationCenterHandler) 方法实现，属于 `AppMetricaPush` 类。

## Instance methods {#instance_summary}

#|
|| [userNotificationCenterWillPresent(_:)](#method_userNotificationCenterWillPresentNotification) | 您应该在 [userNotificationCenter(_:willPresent:withCompletionHandler:)](https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/1649518-usernotificationcenter?language=swift) 的实现中调用此方法。 ||
|| [userNotificationCenterDidReceive(_:)](#method_userNotificationCenterDidReceiveNotificationResponse) | 您应该在 [userNotificationCenter(_:didReceive:withCompletionHandler:)](https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/1649501-usernotificationcenter?language=swift) 的实现中调用此方法。 ||
|| [用户通知中心打开设置(_:)](#method_userNotificationCenterOpenSettingsForNotification) | 您应该在 [userNotificationCenter(_:openSettingsFor:)](https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/2981869-usernotificationcenter?language=swift) 的实现中调用此方法。 ||
|#

## Method descriptions {#method_detail}

### userNotificationCenterWillPresent(_:) {#method_userNotificationCenterWillPresentNotification}

```swift translate=no
func userNotificationCenterWillPresent(_ notification: UNNotification?)
```

您应该在 [userNotificationCenter (_: willPresent:withCompletionHandler:)](https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/1649518-usernotificationcenter?language=swift) 的实现中调用此方法。

**参数：**

#|
|| `通知` | [UNNotification](https://developer.apple.com/documentation/usernotifications/unnotification?language=swift) 的实例。 ||
|#

### userNotificationCenterDidReceive(_:) {#method_userNotificationCenterDidReceiveNotificationResponse}

```swift translate=no
func userNotificationCenterDidReceive(_ response: UNNotificationResponse?)
```

您应该在 [userNotificationCenter (_: didReceive:withCompletionHandler:)](https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/1649501-usernotificationcenter?language=swift) 的实现中调用此方法。

**参数：**

#|
|| `通知` | [UNNotificationResponse](https://developer.apple.com/documentation/usernotifications/unnotificationresponse) 的实例。 ||
|#

### userNotificationCenterOpenSettings(_:) {#method_userNotificationCenterOpenSettingsForNotification}

```swift translate=no
func userNotificationCenterOpenSettings(for notification: UNNotification?)
```

您应该在 [userNotificationCenter (_: openSettingsFor:)](https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/2981869-usernotificationcenter?language=swift) 的实现中调用此方法。

**参数：**

#|
|| `通知` | [UNNotification](https://developer.apple.com/documentation/usernotifications/unnotification) 的实例. ||
|#
