Skip to content

Commit

Permalink
fix: address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-chekyrta committed Jun 21, 2024
1 parent c77f727 commit b9ebbae
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 2 additions & 0 deletions OpenEdX/DI/AppAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import Swinject

class BrazeListener: PushNotificationsListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import Swinject
import FirebaseMessaging

class FCMListener: PushNotificationsListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Foundation
import Core
import UIKit
import Swinject
import UserNotifications
import FirebaseCore
import FirebaseMessaging
Expand All @@ -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] = []

Expand All @@ -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)
Expand All @@ -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
}
Expand Down

0 comments on commit b9ebbae

Please sign in to comment.