-
Notifications
You must be signed in to change notification settings - Fork 16
/
CioSettings.swift
51 lines (44 loc) · 1.79 KB
/
CioSettings.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import CioTracking
import Foundation
// Stores all of the SDK settings that can be changed by the mobile app.
// Note: This struct may not contain *all* of the settings that can be changed in the CIO SDK.
public struct CioSettings: Codable {
public var trackUrl: String
public var siteId: String
public var apiKey: String
public var bqSecondsDelay: TimeInterval
public var bqMinNumberTasks: Int
public var trackScreens: Bool
public var debugSdkMode: Bool
public var trackDeviceAttributes: Bool
public func configureCioSdk(config: inout CioSdkConfig) {
config.trackingApiUrl = trackUrl
config.backgroundQueueSecondsDelay = bqSecondsDelay
config.backgroundQueueMinNumberOfTasks = bqMinNumberTasks
config.autoTrackScreenViews = trackScreens
config.autoTrackDeviceAttributes = trackDeviceAttributes
if debugSdkMode {
config.logLevel = .debug
}
}
public func configureCioSdk(config: inout CioNotificationServiceExtensionSdkConfig) {
config.trackingApiUrl = trackUrl
config.autoTrackDeviceAttributes = trackDeviceAttributes
if debugSdkMode {
config.logLevel = .debug
}
}
public static func getFromCioSdk() -> CioSettings {
let sdkConfig = CustomerIO.shared.config!
return CioSettings(
trackUrl: sdkConfig.trackingApiUrl,
siteId: sdkConfig.siteId,
apiKey: sdkConfig.apiKey,
bqSecondsDelay: sdkConfig.backgroundQueueSecondsDelay,
bqMinNumberTasks: sdkConfig.backgroundQueueMinNumberOfTasks,
trackScreens: sdkConfig.autoTrackScreenViews,
debugSdkMode: sdkConfig.logLevel == .debug,
trackDeviceAttributes: sdkConfig.autoTrackDeviceAttributes
)
}
}