@usercentrics/react-native-sdk 2.2.2-RC1 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +96 -0
- package/android/build.gradle +1 -1
- package/android/src/androidTest/java/com/usercentrics/reactnativemodule/RNUsercentricsModuleTest.kt +16 -132
- package/android/src/androidTest/java/com/usercentrics/reactnativemodule/api/FakeUsercentricsProxy.kt +4 -31
- package/android/src/androidTest/java/com/usercentrics/reactnativemodule/mock/GetTCFDataMock.kt +3 -1
- package/android/src/androidTest/java/com/usercentrics/reactnativemodule/mock/GetUSPDataMock.kt +1 -0
- package/android/src/main/java/com/usercentrics/reactnativeusercentrics/RNUsercentricsModule.kt +8 -83
- package/android/src/main/java/com/usercentrics/reactnativeusercentrics/api/UsercentricsProxy.kt +12 -64
- package/android/src/main/java/com/usercentrics/reactnativeusercentrics/extensions/BannerFontExtensions.kt +26 -0
- package/android/src/main/java/com/usercentrics/reactnativeusercentrics/extensions/CCPADataExtensions.kt +1 -0
- package/android/src/main/java/com/usercentrics/reactnativeusercentrics/extensions/FirstLayerOptionsExtensions.kt +39 -14
- package/android/src/main/java/com/usercentrics/reactnativeusercentrics/extensions/TCFDataExtensions.kt +2 -1
- package/android/src/main/java/com/usercentrics/reactnativeusercentrics/extensions/UserOptionsExtensions.kt +12 -0
- package/android/src/main/java/com/usercentrics/reactnativeusercentrics/extensions/UsercentricsReadyStatusExtensions.kt +1 -1
- package/ios/Extensions/BannerSettings+Dict.swift +103 -16
- package/ios/Extensions/CCPAData+Dict.swift +1 -0
- package/ios/Extensions/ReadyStatus+Dict.swift +1 -1
- package/ios/Extensions/UsercentricsOptions+Dict.swift +20 -6
- package/ios/Manager/UsercentricsManager.swift +8 -36
- package/ios/RNUsercentricsModule.swift +35 -63
- package/ios/RNUsercentricsModule.xcodeproj/project.pbxproj +0 -8
- package/lib/Usercentrics.d.ts +4 -5
- package/lib/Usercentrics.js +4 -8
- package/lib/Usercentrics.js.map +1 -1
- package/lib/models/BannerSettings.d.ts +26 -4
- package/lib/models/BannerSettings.js +25 -1
- package/lib/models/BannerSettings.js.map +1 -1
- package/lib/models/CCPAData.d.ts +2 -1
- package/lib/models/CCPAData.js +2 -1
- package/lib/models/CCPAData.js.map +1 -1
- package/lib/models/FirstLayerOptions.d.ts +14 -12
- package/lib/models/FirstLayerOptions.js +10 -8
- package/lib/models/FirstLayerOptions.js.map +1 -1
- package/lib/models/NetworkMode.d.ts +4 -0
- package/lib/models/NetworkMode.js +6 -0
- package/lib/models/NetworkMode.js.map +1 -0
- package/lib/models/SecondLayerOptions.d.ts +7 -3
- package/lib/models/SecondLayerOptions.js +6 -1
- package/lib/models/SecondLayerOptions.js.map +1 -1
- package/lib/models/TCFData.d.ts +2 -1
- package/lib/models/TCFData.js +2 -1
- package/lib/models/TCFData.js.map +1 -1
- package/lib/models/UsercentricsOptions.d.ts +3 -2
- package/lib/models/UsercentricsOptions.js +2 -1
- package/lib/models/UsercentricsOptions.js.map +1 -1
- package/lib/models/UsercentricsReadyStatus.d.ts +2 -2
- package/lib/models/UsercentricsReadyStatus.js +2 -2
- package/lib/models/UsercentricsReadyStatus.js.map +1 -1
- package/lib/models/index.d.ts +12 -12
- package/lib/models/index.js +12 -12
- package/lib/models/index.js.map +1 -1
- package/package.json +79 -79
- package/android/src/main/java/com/usercentrics/reactnativeusercentrics/extensions/UsercentricsUserInterfaceExtensions.kt +0 -45
- package/ios/Extensions/UIFont+UsercentricsFontDict.swift +0 -15
- package/ios/Extensions/UsercentricsUISettings+Dict.swift +0 -27
- package/lib/models/UsercentricsUIOptions.d.ts +0 -18
- package/lib/models/UsercentricsUIOptions.js +0 -21
- package/lib/models/UsercentricsUIOptions.js.map +0 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package com.usercentrics.reactnativeusercentrics.extensions
|
|
2
|
+
|
|
3
|
+
import android.content.res.AssetManager
|
|
4
|
+
import android.graphics.Typeface
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
import com.usercentrics.sdk.BannerFont
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
internal fun ReadableMap.bannerFontFromMap(assetManager: AssetManager): BannerFont? {
|
|
10
|
+
val size = getDoubleOrNull("fontSize") ?: return null
|
|
11
|
+
val regularTypeface = assetManager.createFontFromName(getString("regularFont")) ?: return null
|
|
12
|
+
val boldTypeface = assetManager.createFontFromName(getString("boldFont")) ?: return null
|
|
13
|
+
|
|
14
|
+
return BannerFont(
|
|
15
|
+
regularTypeface,
|
|
16
|
+
boldTypeface,
|
|
17
|
+
size.toFloat()
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
internal fun AssetManager.createFontFromName(fontName: String?): Typeface? {
|
|
22
|
+
if (fontName == null) { return null }
|
|
23
|
+
val fontsFolder = this.list("fonts")
|
|
24
|
+
val regularFontName = fontsFolder?.firstOrNull { it.startsWith(fontName) } ?: return null
|
|
25
|
+
return Typeface.createFromAsset(this, "fonts/$regularFontName")
|
|
26
|
+
}
|
|
@@ -20,12 +20,24 @@ internal fun ReadableMap.bannerSettingsFromMap(assetManager: AssetManager): Bann
|
|
|
20
20
|
val customFont = getMap("font")
|
|
21
21
|
val customLogo = getMap("logo")
|
|
22
22
|
|
|
23
|
+
val rawFirstLayerStyleSettings = getMap("firstLayerSettings")
|
|
24
|
+
val rawSecondLayerStyleSettings = getMap("secondLayerSettings")
|
|
25
|
+
val rawLegalLinkSettings = getString("links")
|
|
26
|
+
|
|
23
27
|
return BannerSettings(
|
|
24
|
-
customFont?.
|
|
25
|
-
customLogo?.
|
|
28
|
+
font = customFont?.bannerFontFromMap(assetManager),
|
|
29
|
+
logo = customLogo?.bannerLogoFromMap(),
|
|
30
|
+
firstLayerSettings = rawFirstLayerStyleSettings?.firstLayerStyleSettingsFromMap(assetManager),
|
|
31
|
+
secondLayerSettings = rawSecondLayerStyleSettings?.secondLayerStyleSettingsFromMap(assetManager),
|
|
32
|
+
links = rawLegalLinkSettings?.legalLinksFromEnumString()
|
|
26
33
|
)
|
|
27
34
|
}
|
|
28
35
|
|
|
36
|
+
internal fun ReadableMap.bannerLogoFromMap(): UsercentricsImage? {
|
|
37
|
+
val logoPath = getString("logoPath") ?: return null
|
|
38
|
+
return UsercentricsImage.ImageUrl(logoPath)
|
|
39
|
+
}
|
|
40
|
+
|
|
29
41
|
internal fun ReadableMap.firstLayerStyleSettingsFromMap(assetManager: AssetManager): FirstLayerStyleSettings {
|
|
30
42
|
return FirstLayerStyleSettings(
|
|
31
43
|
headerImage = getMap("headerImage")?.headerImageFromMap(),
|
|
@@ -44,7 +56,7 @@ internal fun ReadableMap.headerImageFromMap(): HeaderImageSettings? {
|
|
|
44
56
|
return HeaderImageSettings.Hidden
|
|
45
57
|
}
|
|
46
58
|
|
|
47
|
-
val image = getMap("image")?.
|
|
59
|
+
val image = getMap("image")?.bannerLogoFromMap() ?: return null
|
|
48
60
|
|
|
49
61
|
val isExtended = getBooleanOrNull("isExtended") ?: false
|
|
50
62
|
return if (isExtended) {
|
|
@@ -59,21 +71,18 @@ internal fun ReadableMap.headerImageFromMap(): HeaderImageSettings? {
|
|
|
59
71
|
}
|
|
60
72
|
|
|
61
73
|
internal fun ReadableMap.titleFromMap(assetManager: AssetManager): TitleSettings {
|
|
62
|
-
val font = getMap("font")?.usercentricsFontFromMap(assetManager)
|
|
63
74
|
return TitleSettings(
|
|
64
75
|
alignment = getString("alignment")?.sectionAlignmentFromMap(),
|
|
65
76
|
textColor = getString("textColorHex")?.deserializeColor(),
|
|
66
|
-
font =
|
|
67
|
-
textSizeInSp =
|
|
77
|
+
font = assetManager.createFontFromName(getString("fontName")),
|
|
78
|
+
textSizeInSp = getDoubleOrNull("textSize")?.toFloat()
|
|
68
79
|
)
|
|
69
80
|
}
|
|
70
81
|
|
|
71
82
|
internal fun ReadableMap.messageFromMap(assetManager: AssetManager): MessageSettings {
|
|
72
|
-
val font = getMap("font")?.usercentricsFontFromMap(assetManager)
|
|
73
|
-
|
|
74
83
|
return MessageSettings(
|
|
75
|
-
font =
|
|
76
|
-
textSizeInSp =
|
|
84
|
+
font = assetManager.createFontFromName(getString("fontName")),
|
|
85
|
+
textSizeInSp = getDoubleOrNull("textSize")?.toFloat(),
|
|
77
86
|
textColor = getString("textColorHex")?.deserializeColor(),
|
|
78
87
|
alignment = getString("alignment")?.sectionAlignmentFromMap(),
|
|
79
88
|
linkTextColor = getString("linkTextColorHex")?.deserializeColor(),
|
|
@@ -129,15 +138,14 @@ internal fun ReadableMap.buttonLayoutFromMap(
|
|
|
129
138
|
internal fun ReadableMap.buttonSettingsFromMap(
|
|
130
139
|
assetManager: AssetManager
|
|
131
140
|
): ButtonSettings {
|
|
132
|
-
|
|
133
|
-
return ButtonSettings(
|
|
141
|
+
return ButtonSettings(
|
|
134
142
|
type = getString("buttonType")!!.deserializeButtonType(),
|
|
135
143
|
isAllCaps = getBooleanOrNull("isAllCaps"),
|
|
136
|
-
font =
|
|
144
|
+
font = assetManager.createFontFromName(getString("fontName")),
|
|
137
145
|
textColor = getString("textColorHex")?.deserializeColor(),
|
|
138
146
|
backgroundColor = getString("backgroundColorHex")?.deserializeColor(),
|
|
139
147
|
cornerRadius = getIntOrNull("cornerRadius"),
|
|
140
|
-
textSizeInSp =
|
|
148
|
+
textSizeInSp = getDoubleOrNull("textSize")?.toFloat()
|
|
141
149
|
)
|
|
142
150
|
}
|
|
143
151
|
|
|
@@ -145,6 +153,23 @@ internal fun String.deserializeButtonType(): ButtonType {
|
|
|
145
153
|
return ButtonType.valueOf(this)
|
|
146
154
|
}
|
|
147
155
|
|
|
156
|
+
internal fun ReadableMap.secondLayerStyleSettingsFromMap(assetManager: AssetManager): SecondLayerStyleSettings {
|
|
157
|
+
return SecondLayerStyleSettings(
|
|
158
|
+
buttonLayout = getMap("buttonLayout")?.buttonLayoutFromMap(assetManager),
|
|
159
|
+
showCloseButton = getBoolean("showCloseButton"),
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
internal fun String?.legalLinksFromEnumString(): LegalLinksSettings? {
|
|
164
|
+
return when (this) {
|
|
165
|
+
"BOTH" -> LegalLinksSettings.BOTH
|
|
166
|
+
"NONE" -> LegalLinksSettings.NONE
|
|
167
|
+
"FIRST_LAYER_ONLY" -> LegalLinksSettings.FIRST_LAYER_ONLY
|
|
168
|
+
"SECOND_LAYER_ONLY" -> LegalLinksSettings.SECOND_LAYER_ONLY
|
|
169
|
+
else -> null
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
148
173
|
@ColorInt
|
|
149
174
|
internal fun String.deserializeColor(): Int? {
|
|
150
175
|
val colorString: String =
|
|
@@ -10,7 +10,8 @@ internal fun TCFData.serialize(): WritableMap {
|
|
|
10
10
|
"specialFeatures" to specialFeatures.map { it.serialize() },
|
|
11
11
|
"specialPurposes" to specialPurposes.map { it.serialize() },
|
|
12
12
|
"stacks" to stacks.map { it.serialize() },
|
|
13
|
-
"vendors" to vendors.map { it.serialize() }
|
|
13
|
+
"vendors" to vendors.map { it.serialize() },
|
|
14
|
+
"tcString" to tcString
|
|
14
15
|
).toWritableMap()
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -2,6 +2,7 @@ package com.usercentrics.reactnativeusercentrics.extensions
|
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReadableMap
|
|
4
4
|
import com.usercentrics.sdk.UsercentricsOptions
|
|
5
|
+
import com.usercentrics.sdk.models.common.NetworkMode
|
|
5
6
|
import com.usercentrics.sdk.models.common.UsercentricsLoggerLevel
|
|
6
7
|
|
|
7
8
|
internal fun ReadableMap.usercentricsOptionsFromMap(): UsercentricsOptions? {
|
|
@@ -29,6 +30,17 @@ internal fun ReadableMap.usercentricsOptionsFromMap(): UsercentricsOptions? {
|
|
|
29
30
|
usercentricsOptions.defaultLanguage = it
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
getIntOrNull("networkMode")?.let {
|
|
34
|
+
usercentricsOptions.networkMode = when (it) {
|
|
35
|
+
0 -> NetworkMode.WORLD
|
|
36
|
+
1 -> NetworkMode.EU
|
|
37
|
+
else -> {
|
|
38
|
+
assert(false)
|
|
39
|
+
NetworkMode.WORLD
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
32
44
|
usercentricsOptions
|
|
33
45
|
}
|
|
34
46
|
}
|
|
@@ -6,7 +6,7 @@ import com.usercentrics.sdk.UsercentricsReadyStatus
|
|
|
6
6
|
|
|
7
7
|
internal fun UsercentricsReadyStatus.toWritableMap(): WritableMap {
|
|
8
8
|
return Arguments.createMap().apply {
|
|
9
|
-
putBoolean("
|
|
9
|
+
putBoolean("shouldCollectConsent", shouldCollectConsent)
|
|
10
10
|
putArray("consents", consents.toWritableArray())
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -5,25 +5,84 @@ extension BannerSettings {
|
|
|
5
5
|
init?(from dictionary: NSDictionary?) {
|
|
6
6
|
guard let dictionary = dictionary else { return nil }
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
let bannerFontHolder = BannerFontHolder(from: dictionary["font"] as? NSDictionary)
|
|
9
|
+
|
|
10
|
+
let firstLayerStyleSettingsDict = dictionary["firstLayerSettings"] as? NSDictionary
|
|
11
|
+
let firstLayerSettings = FirstLayerStyleSettings(from: firstLayerStyleSettingsDict, bannerFontHolder: bannerFontHolder)
|
|
12
|
+
|
|
13
|
+
let secondLayerStyleSettingsDict = dictionary["secondLayerSettings"] as? NSDictionary
|
|
14
|
+
let secondLayerSettings = SecondLayerStyleSettings(from: secondLayerStyleSettingsDict, bannerFontHolder: bannerFontHolder)
|
|
15
|
+
|
|
16
|
+
let links = LegalLinksSettings.from(enumString: dictionary["links"] as? String)
|
|
17
|
+
|
|
18
|
+
self.init(font: bannerFontHolder?.font,
|
|
19
|
+
logo: UIImage(from: dictionary["logo"] as? NSDictionary),
|
|
20
|
+
links: links,
|
|
21
|
+
firstLayerSettings: firstLayerSettings,
|
|
22
|
+
secondLayerSettings: secondLayerSettings)
|
|
10
23
|
}
|
|
11
24
|
}
|
|
12
25
|
|
|
13
|
-
|
|
26
|
+
struct BannerFontHolder {
|
|
27
|
+
public let font: BannerFont
|
|
28
|
+
|
|
29
|
+
public let regularFont: UIFont
|
|
30
|
+
public let boldFont: UIFont
|
|
31
|
+
|
|
14
32
|
init?(from dictionary: NSDictionary?) {
|
|
33
|
+
guard let dictionary = dictionary,
|
|
34
|
+
let regularFontName: String = dictionary["regularFont"] as? String,
|
|
35
|
+
let boldFontName: String = dictionary["boldFont"] as? String,
|
|
36
|
+
let fontSize: CGFloat = dictionary["fontSize"] as? CGFloat,
|
|
37
|
+
let regularFont = UIFont(name: regularFontName, size: fontSize),
|
|
38
|
+
let boldFont = UIFont(name: boldFontName, size: fontSize)
|
|
39
|
+
else { return nil }
|
|
40
|
+
|
|
41
|
+
self.regularFont = regularFont
|
|
42
|
+
self.boldFont = boldFont
|
|
43
|
+
self.font = .init(regularFont: regularFont, boldFont: boldFont)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
extension UIFont {
|
|
48
|
+
static func initialize(from fontName: String?, fontSizeValue: CGFloat?, fallbackFont: UIFont?) -> UIFont? {
|
|
49
|
+
let fontSize = fontSizeValue ?? UIFont.systemFontSize
|
|
50
|
+
|
|
51
|
+
// System font with custom size
|
|
52
|
+
if fontName == nil, fontSizeValue != nil {
|
|
53
|
+
return fallbackFont?.withSize(fontSize) ?? UIFont.systemFont(ofSize: fontSize)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if let fontName = fontName {
|
|
57
|
+
return UIFont(name: fontName, size: fontSize)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return fallbackFont?.withSize(fontSize)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
extension FirstLayerStyleSettings {
|
|
65
|
+
init?(from dictionary: NSDictionary?, bannerFontHolder: BannerFontHolder?) {
|
|
15
66
|
guard let dictionary = dictionary else { return nil }
|
|
16
67
|
|
|
17
68
|
self.init(headerImage: HeaderImageSettings.from(dictionary: dictionary["headerImage"] as? NSDictionary),
|
|
18
|
-
title: TitleSettings(from: dictionary["title"] as? NSDictionary),
|
|
19
|
-
message: MessageSettings(from: dictionary["message"] as? NSDictionary),
|
|
20
|
-
buttonLayout: ButtonLayout.from(dictionary: dictionary["buttonLayout"] as? NSDictionary),
|
|
69
|
+
title: TitleSettings(from: dictionary["title"] as? NSDictionary, fallbackFont: bannerFontHolder?.boldFont),
|
|
70
|
+
message: MessageSettings(from: dictionary["message"] as? NSDictionary, fallbackFont: bannerFontHolder?.regularFont),
|
|
71
|
+
buttonLayout: ButtonLayout.from(dictionary: dictionary["buttonLayout"] as? NSDictionary, fallbackFont: bannerFontHolder?.boldFont),
|
|
21
72
|
backgroundColor: UIColor(unsafeHex: dictionary["backgroundColorHex"] as? String),
|
|
22
73
|
cornerRadius: dictionary["cornerRadius"] as? CGFloat,
|
|
23
74
|
overlayColor: UIColor(unsafeHex: dictionary["overlayColorHex"] as? String))
|
|
24
75
|
}
|
|
25
76
|
}
|
|
26
77
|
|
|
78
|
+
extension SecondLayerStyleSettings {
|
|
79
|
+
init?(from dictionary: NSDictionary?, bannerFontHolder: BannerFontHolder?) {
|
|
80
|
+
guard let dictionary = dictionary else { return nil }
|
|
81
|
+
|
|
82
|
+
self.init(buttonLayout: ButtonLayout.from(dictionary: dictionary["buttonLayout"] as? NSDictionary, fallbackFont: bannerFontHolder?.boldFont),
|
|
83
|
+
showCloseButton: dictionary["showCloseButton"] as? Bool)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
27
86
|
|
|
28
87
|
extension HeaderImageSettings {
|
|
29
88
|
static func from(dictionary: NSDictionary?) -> HeaderImageSettings? {
|
|
@@ -50,10 +109,13 @@ extension HeaderImageSettings {
|
|
|
50
109
|
}
|
|
51
110
|
|
|
52
111
|
extension TitleSettings {
|
|
53
|
-
init?(from dictionary: NSDictionary?) {
|
|
112
|
+
init?(from dictionary: NSDictionary?, fallbackFont: UIFont? = nil) {
|
|
54
113
|
guard let dictionary = dictionary else { return nil }
|
|
55
114
|
|
|
56
|
-
|
|
115
|
+
let fontName: String? = dictionary["fontName"] as? String
|
|
116
|
+
let fontSize: CGFloat? = dictionary["textSize"] as? CGFloat
|
|
117
|
+
|
|
118
|
+
self.init(font: UIFont.initialize(from: fontName, fontSizeValue: fontSize, fallbackFont: fallbackFont),
|
|
57
119
|
textColor: UIColor(unsafeHex: dictionary["textColorHex"] as? String ?? ""),
|
|
58
120
|
textAlignment: NSTextAlignment.from(enumString: dictionary["textAlignment"] as? String))
|
|
59
121
|
}
|
|
@@ -61,10 +123,13 @@ extension TitleSettings {
|
|
|
61
123
|
|
|
62
124
|
|
|
63
125
|
extension MessageSettings {
|
|
64
|
-
init?(from dictionary: NSDictionary?) {
|
|
126
|
+
init?(from dictionary: NSDictionary?, fallbackFont: UIFont? = nil) {
|
|
65
127
|
guard let dictionary = dictionary else { return nil }
|
|
66
128
|
|
|
67
|
-
|
|
129
|
+
let fontName: String? = dictionary["fontName"] as? String
|
|
130
|
+
let textSize: CGFloat? = dictionary["textSize"] as? CGFloat
|
|
131
|
+
|
|
132
|
+
self.init(font: UIFont.initialize(from: fontName, fontSizeValue: textSize, fallbackFont: fallbackFont),
|
|
68
133
|
textColor: UIColor(unsafeHex: dictionary["textColorHex"] as? String ?? ""),
|
|
69
134
|
textAlignment: NSTextAlignment.from(enumString: dictionary["textAlignment"] as? String),
|
|
70
135
|
linkTextColor: UIColor(unsafeHex: dictionary["linkTextColorHex"] as? String ?? ""),
|
|
@@ -73,7 +138,7 @@ extension MessageSettings {
|
|
|
73
138
|
}
|
|
74
139
|
|
|
75
140
|
extension ButtonLayout {
|
|
76
|
-
static func from(dictionary: NSDictionary?) -> ButtonLayout? {
|
|
141
|
+
static func from(dictionary: NSDictionary?, fallbackFont: UIFont? = nil) -> ButtonLayout? {
|
|
77
142
|
guard let dictionary = dictionary else { return nil }
|
|
78
143
|
|
|
79
144
|
let layoutDict = dictionary["layout"] as? String
|
|
@@ -81,11 +146,11 @@ extension ButtonLayout {
|
|
|
81
146
|
|
|
82
147
|
switch layoutDict {
|
|
83
148
|
case "ROW":
|
|
84
|
-
return .row(buttons: buttons.flatMap { $0 }.compactMap { ButtonSettings(from: $0) })
|
|
149
|
+
return .row(buttons: buttons.flatMap { $0 }.compactMap { ButtonSettings(from: $0, fallbackFont: fallbackFont) })
|
|
85
150
|
case "COLUMN":
|
|
86
|
-
return .column(buttons: buttons.flatMap { $0 }.compactMap { ButtonSettings(from: $0) })
|
|
151
|
+
return .column(buttons: buttons.flatMap { $0 }.compactMap { ButtonSettings(from: $0, fallbackFont: fallbackFont) })
|
|
87
152
|
case "GRID":
|
|
88
|
-
let gridButtons = buttons.map { $0.compactMap { button in ButtonSettings(from: button) }}
|
|
153
|
+
let gridButtons = buttons.map { $0.compactMap { button in ButtonSettings(from: button, fallbackFont: fallbackFont) }}
|
|
89
154
|
return .grid(buttons: gridButtons)
|
|
90
155
|
default:
|
|
91
156
|
break
|
|
@@ -96,15 +161,18 @@ extension ButtonLayout {
|
|
|
96
161
|
}
|
|
97
162
|
|
|
98
163
|
extension ButtonSettings {
|
|
99
|
-
init?(from dictionary: NSDictionary?) {
|
|
164
|
+
init?(from dictionary: NSDictionary?, fallbackFont: UIFont? = nil) {
|
|
100
165
|
guard
|
|
101
166
|
let dictionary = dictionary,
|
|
102
167
|
let buttonTypeDict = dictionary["buttonType"] as? String,
|
|
103
168
|
let buttonType = ButtonType.from(enumString: buttonTypeDict)
|
|
104
169
|
else { return nil }
|
|
105
170
|
|
|
171
|
+
let fontName: String? = dictionary["fontName"] as? String
|
|
172
|
+
let textSize: CGFloat? = dictionary["textSize"] as? CGFloat
|
|
173
|
+
|
|
106
174
|
self.init(type: buttonType,
|
|
107
|
-
font: UIFont(from:
|
|
175
|
+
font: UIFont.initialize(from: fontName, fontSizeValue: textSize, fallbackFont: fallbackFont),
|
|
108
176
|
textColor: UIColor(unsafeHex: dictionary["textColorHex"] as? String),
|
|
109
177
|
backgroundColor: UIColor(unsafeHex: dictionary["backgroundColorHex"] as? String),
|
|
110
178
|
cornerRadius: dictionary["cornerRadius"] as? CGFloat)
|
|
@@ -178,3 +246,22 @@ extension NSTextAlignment {
|
|
|
178
246
|
}
|
|
179
247
|
}
|
|
180
248
|
}
|
|
249
|
+
|
|
250
|
+
extension LegalLinksSettings {
|
|
251
|
+
static func from(enumString: String?) -> LegalLinksSettings? {
|
|
252
|
+
guard let enumString = enumString else { return nil }
|
|
253
|
+
|
|
254
|
+
switch enumString {
|
|
255
|
+
case "BOTH":
|
|
256
|
+
return .both
|
|
257
|
+
case "FIRST_LAYER_ONLY":
|
|
258
|
+
return .firstLayerOnly
|
|
259
|
+
case "NONE":
|
|
260
|
+
return LegalLinksSettings.none
|
|
261
|
+
case "SECOND_LAYER_ONLY":
|
|
262
|
+
return .secondLayerOnly
|
|
263
|
+
default:
|
|
264
|
+
return nil
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
@@ -2,7 +2,7 @@ import Foundation
|
|
|
2
2
|
import Usercentrics
|
|
3
3
|
|
|
4
4
|
public extension UsercentricsOptions {
|
|
5
|
-
|
|
5
|
+
static func initialize(from dictionary: NSDictionary) -> UsercentricsOptions? {
|
|
6
6
|
guard let settingsId = dictionary["settingsId"] as? String else {
|
|
7
7
|
return nil
|
|
8
8
|
}
|
|
@@ -25,11 +25,11 @@ public extension UsercentricsOptions {
|
|
|
25
25
|
options.version = version
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
if let networkModeValue = dictionary["networkMode"] as? Int {
|
|
29
|
+
options.networkMode = NetworkMode.initialize(from: networkModeValue)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return options
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -47,3 +47,17 @@ public extension UsercentricsLoggerLevel {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
public extension NetworkMode {
|
|
52
|
+
static func initialize(from value: Int) -> NetworkMode {
|
|
53
|
+
switch value {
|
|
54
|
+
case 0:
|
|
55
|
+
return NetworkMode.world
|
|
56
|
+
case 1:
|
|
57
|
+
return NetworkMode.eu
|
|
58
|
+
default:
|
|
59
|
+
assert(false)
|
|
60
|
+
return NetworkMode.world
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -8,26 +8,21 @@ public protocol UsercentricsManager {
|
|
|
8
8
|
func isReady(onSuccess: @escaping ((UsercentricsReadyStatus) -> Void), onFailure: @escaping ((Error) -> Void))
|
|
9
9
|
func restoreUserSession(controllerId: String, onSuccess: @escaping ((UsercentricsReadyStatus) -> Void), onFailure: @escaping ((Error) -> Void))
|
|
10
10
|
|
|
11
|
-
func getPredefinedUI(settings: UsercentricsUISettings?, dismissViewHandler: @escaping (UsercentricsConsentUserResponse) -> Void) -> UIViewController
|
|
12
|
-
|
|
13
11
|
func showFirstLayer(bannerSettings: BannerSettings?,
|
|
14
|
-
hostView:
|
|
12
|
+
hostView: UIViewController,
|
|
15
13
|
layout: UsercentricsLayout,
|
|
16
|
-
settings: FirstLayerStyleSettings?,
|
|
17
14
|
dismissViewHandler: @escaping (UsercentricsConsentUserResponse) -> Void)
|
|
18
15
|
|
|
19
16
|
func showSecondLayer(bannerSettings: BannerSettings?,
|
|
20
|
-
hostView:
|
|
21
|
-
showCloseButton: Bool,
|
|
17
|
+
hostView: UIViewController,
|
|
22
18
|
dismissViewHandler: @escaping (UsercentricsConsentUserResponse) -> Void)
|
|
23
19
|
|
|
24
|
-
func getTCString() -> String
|
|
25
20
|
func getControllerId() -> String
|
|
26
21
|
func getConsents() -> [UsercentricsServiceConsent]
|
|
27
22
|
func getCMPData() -> UsercentricsCMPData
|
|
28
23
|
func getUserSessionData() -> String
|
|
29
24
|
func getUSPData() -> CCPAData
|
|
30
|
-
func getTCFData() ->
|
|
25
|
+
func getTCFData(callback: @escaping (TCFData) -> Void)
|
|
31
26
|
|
|
32
27
|
func changeLanguage(language: String, onSuccess: @escaping (() -> Void), onFailure: @escaping ((Error) -> Void))
|
|
33
28
|
|
|
@@ -55,15 +50,6 @@ final class UsercentricsManagerImplementation: UsercentricsManager {
|
|
|
55
50
|
}
|
|
56
51
|
|
|
57
52
|
func configure(options: UsercentricsOptions) {
|
|
58
|
-
var isConfigured: Bool = false
|
|
59
|
-
isReady { _ in
|
|
60
|
-
isConfigured = true
|
|
61
|
-
} onFailure: { _ in
|
|
62
|
-
isConfigured = true
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
guard !isConfigured else { return }
|
|
66
|
-
|
|
67
53
|
UsercentricsCore.configure(options: options)
|
|
68
54
|
}
|
|
69
55
|
|
|
@@ -71,39 +57,25 @@ final class UsercentricsManagerImplementation: UsercentricsManager {
|
|
|
71
57
|
UsercentricsCore.reset()
|
|
72
58
|
}
|
|
73
59
|
|
|
74
|
-
func getPredefinedUI(settings: UsercentricsUISettings?, dismissViewHandler: @escaping (UsercentricsConsentUserResponse) -> Void) -> UIViewController {
|
|
75
|
-
return UsercentricsUserInterface.getPredefinedUI(settings: settings, dismissViewHandler: dismissViewHandler)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
60
|
func showFirstLayer(bannerSettings: BannerSettings?,
|
|
79
|
-
hostView:
|
|
61
|
+
hostView: UIViewController,
|
|
80
62
|
layout: UsercentricsLayout,
|
|
81
|
-
settings: FirstLayerStyleSettings?,
|
|
82
63
|
dismissViewHandler: @escaping (UsercentricsConsentUserResponse) -> Void) {
|
|
83
64
|
UsercentricsBanner(bannerSettings: bannerSettings).showFirstLayer(hostView: hostView,
|
|
84
65
|
layout: layout,
|
|
85
|
-
settings: settings,
|
|
86
66
|
completionHandler: dismissViewHandler)
|
|
87
67
|
}
|
|
88
68
|
|
|
89
69
|
func showSecondLayer(bannerSettings: BannerSettings?,
|
|
90
|
-
hostView:
|
|
91
|
-
showCloseButton: Bool,
|
|
70
|
+
hostView: UIViewController,
|
|
92
71
|
dismissViewHandler: @escaping (UsercentricsConsentUserResponse) -> Void) {
|
|
93
|
-
UsercentricsBanner(bannerSettings: bannerSettings).showSecondLayer(hostView: hostView,
|
|
94
|
-
showCloseButton: showCloseButton,
|
|
95
|
-
presentationMode: .present,
|
|
96
|
-
completionHandler: dismissViewHandler)
|
|
72
|
+
UsercentricsBanner(bannerSettings: bannerSettings).showSecondLayer(hostView: hostView, completionHandler: dismissViewHandler)
|
|
97
73
|
}
|
|
98
74
|
|
|
99
75
|
func restoreUserSession(controllerId: String, onSuccess: @escaping ((UsercentricsReadyStatus) -> Void), onFailure: @escaping ((Error) -> Void)) {
|
|
100
76
|
UsercentricsCore.shared.restoreUserSession(controllerId: controllerId, onSuccess: onSuccess, onFailure: onFailure)
|
|
101
77
|
}
|
|
102
78
|
|
|
103
|
-
func getTCString() -> String {
|
|
104
|
-
return UsercentricsCore.shared.getTCString()
|
|
105
|
-
}
|
|
106
|
-
|
|
107
79
|
func getControllerId() -> String {
|
|
108
80
|
return UsercentricsCore.shared.getControllerId()
|
|
109
81
|
}
|
|
@@ -124,8 +96,8 @@ final class UsercentricsManagerImplementation: UsercentricsManager {
|
|
|
124
96
|
return UsercentricsCore.shared.getUSPData()
|
|
125
97
|
}
|
|
126
98
|
|
|
127
|
-
func getTCFData() ->
|
|
128
|
-
|
|
99
|
+
func getTCFData(callback: @escaping (TCFData) -> Void) {
|
|
100
|
+
UsercentricsCore.shared.getTCFData(callback: callback)
|
|
129
101
|
}
|
|
130
102
|
|
|
131
103
|
func changeLanguage(language: String, onSuccess: @escaping (() -> Void), onFailure: @escaping ((Error) -> Void)) {
|