Skip to content

Commit

Permalink
Make sure it builds on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Feb 18, 2024
1 parent 9b7edc5 commit f904c09
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ import UserNotifications

/// Get notified about receiving notifications.
public protocol NotificationHandler {
#if !os(tvOS)
/// Handle user-selected notification action.
///
/// This method is called with your app in the background to handle the selected user action.
///
/// For more information refer to [Handle user-selected actions](https://developer.apple.com/documentation/usernotifications/handling-notifications-and-notification-related-actions#Handle-user-selected-actions)
/// and [`userNotificationCenter(_:didReceive:withCompletionHandler:)`](https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/usernotificationcenter(_:didreceive:withcompletionhandler:)).
///
/// - Note: Notification Actions are not supported on `tvOS`.
///
/// - Parameter response: The user's response to the notification.
func handleNotificationAction(_ response: UNNotificationResponse) async
#endif

/// Handle incoming notification when the app is running in foreground.
///
Expand All @@ -43,6 +47,8 @@ public protocol NotificationHandler {
/// [`application(_:didReceiveRemoteNotification:fetchCompletionHandler:)`](https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623013-application)
/// or [`didReceiveRemoteNotification(_:fetchCompletionHandler:)`](https://developer.apple.com/documentation/watchkit/wkextensiondelegate/3152235-didreceiveremotenotification).
///
/// - Note: The signature for this method on macOS is slightly different. It is not `async` and doesn't have a return value.
///
/// - Parameter remoteNotification: The data of the notification payload.
/// - Returns: Return the respective ``BackgroundFetchResult``.
func receiveRemoteNotification(_ remoteNotification: [AnyHashable: Any]) async -> BackgroundFetchResult
Expand All @@ -62,8 +68,10 @@ public protocol NotificationHandler {


extension NotificationHandler {
#if !os(tvOS)
/// Empty default implementation.
func handleNotificationAction(_ response: UNNotificationResponse) async {}
#endif

/// Empty default implementation.
func receiveIncomingNotification(_ notification: UNNotification) async -> UNNotificationPresentationOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ SPDX-License-Identifier: MIT

<!--@START_MENU_TOKEN@-->Text<!--@END_MENU_TOKEN@-->

### Section header

## Topics

### Application Interaction
Expand Down
2 changes: 0 additions & 2 deletions Sources/Spezi/Spezi.docc/Module/Module Communication.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ SPDX-License-Identifier: MIT

## Overview

### Communication

``Module``s can easily communicate with each other using the ``Module/Provide`` and ``Module/Collect`` property wrappers.

Upon configuration, the value of each ``Module/Collect`` property will be collected. Therefore,
Expand Down
2 changes: 2 additions & 0 deletions Sources/Spezi/Spezi/SpeziNotificationCenterDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import UserNotifications


class SpeziNotificationCenterDelegate: NSObject, UNUserNotificationCenterDelegate {
#if !os(tvOS)
@MainActor
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
guard let delegate = SpeziAppDelegate.appDelegate else {
Expand All @@ -26,6 +27,7 @@ class SpeziNotificationCenterDelegate: NSObject, UNUserNotificationCenterDelegat
for await _ in group {}
}
}
#endif

@MainActor
func userNotificationCenter(
Expand Down

0 comments on commit f904c09

Please sign in to comment.