File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 11// Copyright 2023–2025 Skip
22// SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
33#if !SKIP_BRIDGE
4- #if canImport(UIKit) // UNUserNotificationCenter does not exist on macOS
54import Foundation
65#if !SKIP
6+ #if canImport(UIKit) // UNUserNotificationCenter does not exist on macOS
77import UIKit
8+ #endif
89import OSLog
910#else
1011import kotlinx. coroutines. CoroutineScope
@@ -29,6 +30,9 @@ public class SkipNotify {
2930 #if SKIP
3031 FirebaseMessaging . getInstance ( ) . token. await ( )
3132 #else
33+ #if !canImport(UIKit) // UNUserNotificationCenter does not exist on macOS
34+ throw SkipNotifyError ( message: " UIKit required for notifications on Darwin platforms " )
35+ #else
3236 UNUserNotificationCenter . current ( ) . delegate = notificationCenterDelegate
3337
3438 // these notifications are added to the default UIApplicationDelegate
@@ -75,9 +79,11 @@ public class SkipNotify {
7579 }
7680 }
7781 #endif
82+ #endif
7883 }
7984
8085 #if !SKIP
86+ #if canImport(UIKit)
8187 let notificationCenterDelegate = NotificationCenterDelegate ( )
8288
8389 class NotificationCenterDelegate : NSObject , UNUserNotificationCenterDelegate {
@@ -100,7 +106,24 @@ public class SkipNotify {
100106
101107 }
102108 #endif
109+ #endif
110+ }
111+
112+ /// Thrown on notify error.
113+ public struct SkipNotifyError : LocalizedError , CustomStringConvertible {
114+ let message : String
115+
116+ init ( message: String ) {
117+ self . message = message
118+ }
119+
120+ public var description : String {
121+ return message
122+ }
123+
124+ public var errorDescription : String ? {
125+ return message
126+ }
103127}
104128
105- #endif
106129#endif
You can’t perform that action at this time.
0 commit comments