Skip to content

Commit fedae1e

Browse files
committed
Merge branch 'release/1.2.3' into main
2 parents e5c0c74 + e1e9e74 commit fedae1e

11 files changed

+693
-29
lines changed

Sources/Pam/HttpClient.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ enum HttpClient {
7575
request.addValue($0.value, forHTTPHeaderField: $0.key)
7676
}
7777

78+
79+
if Pam.shared.isEnableLog {
80+
print("🛺 Request GET: ", url )
81+
}
82+
7883
let session = URLSession.shared
7984
session.dataTask(with: request) { data, _, error in
8085
if error == nil, let data = data {

Sources/Pam/Pam+StandardEvent.swift

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@
77

88
import Foundation
99

10-
extension Pam {
11-
class StandardEvent {
12-
struct PageView: PamEvent {
13-
14-
let pageURL:String?
15-
16-
func getPayload() -> [String : Any] {
17-
return [:]
18-
}
19-
20-
func getEvent() -> String {
21-
return ""
22-
}
10+
11+
public class PamStandardEvent {
12+
13+
public static func pageView(pageName:String, pageURL:String?, contentID: String?, payload: [String:Any]?) {
14+
15+
var payload = payload
16+
payload?["page_title"] = pageName
17+
payload?["page_url"] = pageURL
18+
19+
if let id = contentID {
20+
payload?["id"] = id
2321
}
22+
23+
Pam.track(event: "page_view",
24+
payload: payload)
2425
}
2526
}

Sources/Pam/Pam+Static.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ extension Pam {
1818

1919
}
2020

21+
public static func getContactID()->String?{
22+
return Pam.shared.getContactID()
23+
}
24+
25+
public static func getDeviceUUID()->String?{
26+
return UIDevice.current.identifierForVendor?.uuidString
27+
}
28+
2129
public static func userLogin() {
2230
Pam.shared.updateCustomerID()
2331
}
@@ -142,4 +150,35 @@ extension Pam {
142150
Pam.shared.setDeviceToken(deviceToken: token)
143151
}
144152

153+
static public func createNotificationReader(notificationData: [String: Any]?) -> PAMNotificationReader? {
154+
155+
if let pamNoti = notificationData?["pam"] as? [String: String] {
156+
let url = pamNoti["url"]
157+
let flex = pamNoti["flex"]
158+
let pixel = pamNoti["pixel"]
159+
160+
if let flex = flex {
161+
let parser = FlexLangParser()
162+
if let flexVC = parser.parse(flex: flex)?.render() {
163+
return PAMNotificationReader(.reader, pixel: pixel, viewController: flexVC)
164+
}
165+
}
166+
167+
if let url = url {
168+
if url.hasPrefix("http") {
169+
return PAMNotificationReader(.url, pixel: pixel, url: url)
170+
} else {
171+
return PAMNotificationReader(.scheme, pixel: pixel, url: url)
172+
}
173+
}
174+
}
175+
176+
return nil
177+
}
178+
179+
public static func resolvePixel(_ url: String?){
180+
guard let url = url else{return}
181+
HttpClient.getReturnData(url: url, queryString: nil, headers: nil, onSuccess: nil)
182+
}
183+
145184
}

Sources/Pam/Pam.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public class Pam: NSObject {
339339
formField["_database"] = config?.publicDBAlias ?? ""
340340
}
341341

342-
if let uuid = UIDevice.current.identifierForVendor?.uuidString {
342+
if let uuid = Pam.getDeviceUUID() {
343343
formField["uuid"] = uuid
344344
}
345345

@@ -472,6 +472,8 @@ public class Pam: NSObject {
472472
}
473473
dispatch("onToken", data: ["token": deviceToken])
474474
}
475+
476+
475477
}
476478

477479

Sources/Pam/PamEvent.swift

Lines changed: 0 additions & 13 deletions
This file was deleted.

Sources/Pam/consent/ConsentAPI.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class ConsentAPI {
9191
}
9292

9393
Pam.track(event: "allow_consent", payload: payload){ res in
94-
self.resultSubmit?["consent.id"] = AllowConsentResult(contactID: res.contactID, database: res.database, consentID: res.consentID)
94+
self.resultSubmit?[consent.id] = AllowConsentResult(contactID: res.contactID, database: res.database, consentID: res.consentID)
9595
self.startSubmit()
9696
}
9797
}
@@ -117,6 +117,8 @@ class ConsentAPI {
117117
isLoading = true
118118
let pamServerURL = Pam.shared.config?.pamServer ?? ""
119119

120+
print("LOAD CONSENT = ","\(pamServerURL)/consent-message/\(consentMessageID)")
121+
120122
HttpClient.getReturnData(url: "\(pamServerURL)/consent-message/\(consentMessageID)", queryString: nil, headers: nil){ data in
121123

122124
if let data = data {

Sources/Pam/consent/ConsentMessage.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public struct ConsentMessage: BaseConsentMessage{
127127
public let availableLanguages: [String]
128128
public let defaultLanguage: String
129129
public var permission: [ConsentPermission]
130+
public let moreInfoButtonText: Text?
130131

131132
public func allowAll(){
132133
for var item in permission{
@@ -199,6 +200,11 @@ public struct ConsentMessage: BaseConsentMessage{
199200
let version = setting[\.version].int ?? 0
200201
let revision = setting[\.version].int ?? 0
201202
let displayText = getText(json: setting[\.display_text].json)
203+
204+
let moreInfoButtonText = getText(json: setting[\.more_info.display_text].json)
205+
206+
//let moreInfoCustomURL = getText(json: setting[\.more_info.display_text].json)
207+
202208
let acceptButtonText = getText(json: setting[\.accept_button_text].json)
203209
let consentDetailTitle = getText(json: setting[\.consent_detail_title])
204210

@@ -228,7 +234,9 @@ public struct ConsentMessage: BaseConsentMessage{
228234
consentDetailTitle: consentDetailTitle,
229235
availableLanguages: availableLanguages,
230236
defaultLanguage: defaultLanguage,
231-
permission: permissions)
237+
permission: permissions,
238+
moreInfoButtonText: moreInfoButtonText
239+
)
232240
}
233241

234242
}
@@ -260,6 +268,12 @@ public struct ConsentPermission{
260268

261269
if let item = json?[dynamicMember: key.key].json {
262270

271+
let isEnable = item[\.is_enabled].bool ?? false
272+
if !isEnable {
273+
return nil
274+
}
275+
276+
263277
let shortDescription = item[\.brief_description].json
264278
let fullDescription = item[\.full_description].json
265279
let fullDescriptionEnabled = item[\.is_full_description_enabled].bool ?? false

0 commit comments

Comments
 (0)