Tusker/Packages/PushNotifications/Sources/PushNotifications/DisabledPushManager.swift

60 lines
1.3 KiB
Swift

//
// DisabledPushManager.swift
// PushNotifications
//
// Created by Shadowfacts on 4/7/24.
//
import Foundation
import UserAccounts
class DisabledPushManager: _PushManager {
var enabled: Bool {
false
}
var proxyRegistration: PushProxyRegistration? {
nil
}
var subscriptions: [PushSubscription] {
[]
}
func createSubscription(account: UserAccountInfo) throws -> PushSubscription {
throw Disabled()
}
func removeSubscription(account: UserAccountInfo) {
}
func updateSubscription(account: UserAccountInfo, alerts: PushSubscription.Alerts, policy: PushSubscription.Policy) {
}
func pushSubscription(account: UserAccountInfo) -> PushSubscription? {
nil
}
func register() async throws -> PushProxyRegistration {
throw Disabled()
}
func unregister() async throws {
throw Disabled()
}
func updateIfNecessary(updateSubscription: @escaping (PushSubscription) async -> Bool) async {
}
func didRegisterForRemoteNotifications(deviceToken: Data) {
}
func didFailToRegisterForRemoteNotifications(error: any Error) {
}
struct Disabled: LocalizedError {
var errorDescription: String? {
"Push notifications disabled"
}
}
}