mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Extract shared notification presention/response Implement adapters which use that logic for modern UNUserNotification and legacy UINotifications
84 lines
2.1 KiB
Swift
84 lines
2.1 KiB
Swift
//
|
|
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import SignalServiceKit
|
|
import SignalMessaging
|
|
|
|
@objc public class AppEnvironment: NSObject {
|
|
|
|
private static var _shared: AppEnvironment = AppEnvironment()
|
|
|
|
@objc
|
|
public class var shared: AppEnvironment {
|
|
get {
|
|
return _shared
|
|
}
|
|
set {
|
|
guard CurrentAppContext().isRunningTests else {
|
|
owsFailDebug("Can only switch environments in tests.")
|
|
return
|
|
}
|
|
|
|
_shared = newValue
|
|
}
|
|
}
|
|
|
|
@objc
|
|
public var callMessageHandler: WebRTCCallMessageHandler
|
|
|
|
@objc
|
|
public var callService: CallService
|
|
|
|
@objc
|
|
public var outboundCallInitiator: OutboundCallInitiator
|
|
|
|
@objc
|
|
public var messageFetcherJob: MessageFetcherJob
|
|
|
|
@objc
|
|
public var accountManager: AccountManager
|
|
|
|
@objc
|
|
public var notificationPresenter: NotificationPresenter
|
|
|
|
@objc
|
|
public var pushRegistrationManager: PushRegistrationManager
|
|
|
|
@objc
|
|
public var sessionResetJobQueue: SessionResetJobQueue
|
|
|
|
@objc
|
|
public var backup: OWSBackup
|
|
|
|
@objc
|
|
public var backupLazyRestore: BackupLazyRestore
|
|
|
|
private override init() {
|
|
self.callMessageHandler = WebRTCCallMessageHandler()
|
|
self.callService = CallService()
|
|
self.outboundCallInitiator = OutboundCallInitiator()
|
|
self.messageFetcherJob = MessageFetcherJob()
|
|
self.accountManager = AccountManager()
|
|
self.notificationPresenter = NotificationPresenter()
|
|
self.pushRegistrationManager = PushRegistrationManager()
|
|
self.sessionResetJobQueue = SessionResetJobQueue()
|
|
self.backup = OWSBackup()
|
|
self.backupLazyRestore = BackupLazyRestore()
|
|
|
|
super.init()
|
|
|
|
SwiftSingletons.register(self)
|
|
}
|
|
|
|
@objc
|
|
public func setup() {
|
|
callService.createCallUIAdapter()
|
|
|
|
// Hang certain singletons on SSKEnvironment too.
|
|
SSKEnvironment.shared.notificationsManager = notificationPresenter
|
|
SSKEnvironment.shared.callMessageHandler = callMessageHandler
|
|
}
|
|
}
|