diff --git a/OpenEdX/DI/AppAssembly.swift b/OpenEdX/DI/AppAssembly.swift index a9d71837c..cabc57d33 100644 --- a/OpenEdX/DI/AppAssembly.swift +++ b/OpenEdX/DI/AppAssembly.swift @@ -175,6 +175,8 @@ class AppAssembly: Assembly { container.register(PushNotificationsManager.self) { r in PushNotificationsManager( deepLinkManager: r.resolve(DeepLinkManager.self)!, + storage: r.resolve(CoreStorage.self)!, + api: r.resolve(API.self)!, config: r.resolve(ConfigProtocol.self)! ) }.inObjectScope(.container) diff --git a/OpenEdX/Managers/PushNotificationsManager/Listeners/BrazeListener.swift b/OpenEdX/Managers/PushNotificationsManager/Listeners/BrazeListener.swift index a8925290f..b117843fc 100644 --- a/OpenEdX/Managers/PushNotificationsManager/Listeners/BrazeListener.swift +++ b/OpenEdX/Managers/PushNotificationsManager/Listeners/BrazeListener.swift @@ -6,7 +6,6 @@ // import Foundation -import Swinject class BrazeListener: PushNotificationsListener { diff --git a/OpenEdX/Managers/PushNotificationsManager/Listeners/FCMListener.swift b/OpenEdX/Managers/PushNotificationsManager/Listeners/FCMListener.swift index cd8c7fd81..5d951e1a8 100644 --- a/OpenEdX/Managers/PushNotificationsManager/Listeners/FCMListener.swift +++ b/OpenEdX/Managers/PushNotificationsManager/Listeners/FCMListener.swift @@ -6,7 +6,6 @@ // import Foundation -import Swinject import FirebaseMessaging class FCMListener: PushNotificationsListener { diff --git a/OpenEdX/Managers/PushNotificationsManager/Providers/FCMProvider.swift b/OpenEdX/Managers/PushNotificationsManager/Providers/FCMProvider.swift index c260da056..722d14b0e 100644 --- a/OpenEdX/Managers/PushNotificationsManager/Providers/FCMProvider.swift +++ b/OpenEdX/Managers/PushNotificationsManager/Providers/FCMProvider.swift @@ -13,8 +13,13 @@ import Swinject class FCMProvider: NSObject, PushNotificationsProvider, MessagingDelegate { - private var storage = Container.shared.resolve(CoreStorage.self)! - private let api = Container.shared.resolve(API.self)! + private var storage: CoreStorage + private let api: API + + init(storage: CoreStorage, api: API) { + self.storage = storage + self.api = api + } func didRegisterWithDeviceToken(deviceToken: Data) { Messaging.messaging().apnsToken = deviceToken diff --git a/OpenEdX/Managers/PushNotificationsManager/PushNotificationsManager.swift b/OpenEdX/Managers/PushNotificationsManager/PushNotificationsManager.swift index d91246550..1f6ab02b4 100644 --- a/OpenEdX/Managers/PushNotificationsManager/PushNotificationsManager.swift +++ b/OpenEdX/Managers/PushNotificationsManager/PushNotificationsManager.swift @@ -8,7 +8,6 @@ import Foundation import Core import UIKit -import Swinject import UserNotifications import FirebaseCore import FirebaseMessaging @@ -28,6 +27,8 @@ protocol PushNotificationsListener { class PushNotificationsManager: NSObject { private let deepLinkManager: DeepLinkManager + private let storage: CoreStorage + private let api: API private var providers: [PushNotificationsProvider] = [] private var listeners: [PushNotificationsListener] = [] @@ -36,8 +37,10 @@ class PushNotificationsManager: NSObject { } // Init manager - public init(deepLinkManager: DeepLinkManager, config: ConfigProtocol) { + public init(deepLinkManager: DeepLinkManager, storage: CoreStorage, api: API, config: ConfigProtocol) { self.deepLinkManager = deepLinkManager + self.storage = storage + self.api = api super.init() providers = providersFor(config: config) listeners = listenersFor(config: config) @@ -49,7 +52,7 @@ class PushNotificationsManager: NSObject { pushProviders.append(BrazeProvider()) } if config.firebase.cloudMessagingEnabled { - pushProviders.append(FCMProvider()) + pushProviders.append(FCMProvider(storage: storage, api: api)) } return pushProviders }