Skip to content

Commit

Permalink
chore: push and inapp merge cleanup (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrehan27 authored Dec 6, 2023
1 parent e60e7a2 commit 9b3e4a7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Sources/MessagingInApp/MessagingInApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public class MessagingInApp: ModuleTopLevelObject<MessagingInAppInstance>, Messa
// This function's job is to populate the `shared` property with
// overrides such as DI graph.
init(implementation: MessagingInAppInstance?) {
super.init(moduleName: MessagingInApp.moduleName, implementation: implementation)
super.init(moduleName: Self.moduleName, implementation: implementation)
}

// constructor used in production with default DI graph
// singleton constructor
private init() {
super.init(moduleName: MessagingInApp.moduleName)
super.init(moduleName: Self.moduleName)
}

// for testing
Expand Down
8 changes: 4 additions & 4 deletions Sources/MessagingPush/MessagingPush.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ import Foundation
*/
public class MessagingPush: ModuleTopLevelObject<MessagingPushInstance>, MessagingPushInstance {
@Atomic public private(set) static var shared = MessagingPush()
@Atomic public private(set) static var moduleConfig: MessagingPushConfigOptions = MessagingPushConfigOptions.Factory.create()
@Atomic public private(set) static var moduleConfig: MessagingPushConfigOptions = .Factory.create()
private static let moduleName = "MessagingPush"

private var globalDataStore: GlobalDataStore
// testing constructor
init(implementation: MessagingPushInstance?, globalDataStore: GlobalDataStore) {
self.globalDataStore = globalDataStore
super.init(moduleName: MessagingPush.moduleName, implementation: implementation)
super.init(moduleName: Self.moduleName, implementation: implementation)
}

// singleton constructor
private init() {
self.globalDataStore = CioGlobalDataStore.getInstance()
super.init(moduleName: MessagingPush.moduleName)
super.init(moduleName: Self.moduleName)
}

// for testing
Expand Down Expand Up @@ -53,7 +53,7 @@ public class MessagingPush: ModuleTopLevelObject<MessagingPushInstance>, Messagi
}

logger.debug("Setting up \(moduleName) module...")
let pushImplementation = MessagingPushImplementation(diGraph: DIGraphShared.shared, moduleConfig: MessagingPush.moduleConfig)
let pushImplementation = MessagingPushImplementation(diGraph: DIGraphShared.shared, moduleConfig: Self.moduleConfig)
setImplementationInstance(implementation: pushImplementation)

logger.info("\(moduleName) module successfully set up with SDK")
Expand Down
8 changes: 0 additions & 8 deletions Sources/MessagingPush/MessagingPushConfigOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,4 @@ public struct MessagingPushConfigOptions {
operating system, device locale, device model, app version etc
*/
public var autoTrackDeviceAttributes: Bool

/// Applies new configuration to this object
/// - Important: Ensure all mutable properties are updated accordingly
mutating func apply(_ newConfig: MessagingPushConfigOptions) {
autoFetchDeviceToken = newConfig.autoFetchDeviceToken
autoTrackPushEvents = newConfig.autoTrackPushEvents
autoTrackDeviceAttributes = newConfig.autoTrackDeviceAttributes
}
}
2 changes: 1 addition & 1 deletion Sources/MessagingPush/MessagingPushImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import UserNotifications
#endif

class MessagingPushImplementation: MessagingPushInstance {
var moduleConfig: MessagingPushConfigOptions
let moduleConfig: MessagingPushConfigOptions
let logger: Logger
let jsonAdapter: JsonAdapter

Expand Down

0 comments on commit 9b3e4a7

Please sign in to comment.