Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

Commit 9960d6a

Browse files
resolving conflicts
2 parents c9defb3 + e348305 commit 9960d6a

File tree

60 files changed

+5222
-850
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+5222
-850
lines changed

.github/workflows/swift.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ jobs:
1919
- uses: actions/checkout@v2
2020
- name: CocoaPod Install
2121
run: cd Example && pod install
22-
- name: testing -> iPhone 11 (iOS 13.6)
23-
run: xcodebuild test -scheme ConsentViewController-Example -workspace Example/CCPAConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 11,OS=13.6' CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED="NO"
22+
- name: Example app Unit and UI testing -> iPhone 11 (iOS 14.0)
23+
run: xcodebuild test -scheme ConsentViewController-Example -workspace Example/CCPAConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 11,OS=14.0' CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED="NO"
24+
- name: SourcePointMetaApp UI testing -> iPhone 11 (iOS 14.0)
25+
run: xcodebuild test -scheme SourcePointMetaApp -workspace Example/CCPAConsentViewController.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 11,OS=14.0' CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED="NO"
26+

CCPAConsentViewController.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'CCPAConsentViewController'
3-
s.version = '1.3.1'
3+
s.version = '1.4.0'
44
s.summary = 'SourcePoint\'s CCPAConsentViewController to handle privacy consents.'
55
s.homepage = 'https://www.sourcepoint.com'
66
s.license = { :type => 'MIT', :file => 'LICENSE' }

CCPAConsentViewController/Classes/CCPAConsentViewController.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ public typealias TargetingParams = [String: String]
174174
public func loadMessage(forAuthId authId: String?) {
175175
if loading == .Ready {
176176
loading = .Loading
177-
UserDefaults.standard.setValue(authId, forKey: CCPAConsentViewController.CCPA_AUTH_ID_KEY)
178177
if didAuthIdChange(newAuthId: (authId)) {
179178
resetConsentData()
180179
}
180+
UserDefaults.standard.setValue(authId, forKey: CCPAConsentViewController.CCPA_AUTH_ID_KEY)
181181
sourcePoint.getMessage(consentUUID: consentUUID, authId: authId) { [weak self] messageResponse, error in
182182
self?.loading = .Ready
183183
if let message = messageResponse {
@@ -229,11 +229,11 @@ public typealias TargetingParams = [String: String]
229229

230230
func resetConsentData() {
231231
self.consentUUID = ""
232-
clearAllConsentData()
232+
CCPAConsentViewController.clearAllConsentData()
233233
}
234234

235235
/// Remove all consent related data from the UserDefaults
236-
public func clearAllConsentData() {
236+
static public func clearAllConsentData() {
237237
UserDefaults.standard.removeObject(forKey: CCPAConsentViewController.CCPA_AUTH_ID_KEY)
238238
UserDefaults.standard.removeObject(forKey: CCPAConsentViewController.CCPA_USER_CONSENTS)
239239
UserDefaults.standard.removeObject(forKey: CCPAConsentViewController.CONSENT_UUID_KEY)
@@ -260,9 +260,9 @@ extension CCPAConsentViewController: ConsentDelegate {
260260
public func onError(error: CCPAConsentViewControllerError?) {
261261
loading = .Ready
262262
if shouldCleanConsentOnError {
263-
clearAllConsentData()
263+
CCPAConsentViewController.clearAllConsentData()
264264
}
265-
consentDelegate?.onError?(error: error)
265+
consentDelegate?.onError?(ccpaError: error)
266266
}
267267

268268
public func onAction(_ action: Action, consents: PMConsents?) {

CCPAConsentViewController/Classes/CCPAConsentViewControllerError.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Foundation
1616
}
1717
}
1818

19-
@objcMembers public class GeneralRequestError: CCPAConsentViewControllerError {
19+
@objcMembers public class CCPAGeneralRequestError: CCPAConsentViewControllerError {
2020
public let url, response, error: String
2121

2222
public var failureReason: String? { return "The request to: \(url) failed with response: \(response) and error: \(error)" }
@@ -34,7 +34,7 @@ import Foundation
3434
override public var description: String { return "\(failureReason!)" }
3535
}
3636

37-
@objcMembers public class APIParsingError: CCPAConsentViewControllerError {
37+
@objcMembers public class CCPAAPIParsingError: CCPAConsentViewControllerError {
3838
private let parsingError: Error?
3939
private let endpoint: String
4040

@@ -51,17 +51,17 @@ import Foundation
5151
public var failureReason: String? { return description }
5252
}
5353

54-
@objcMembers public class UnableToLoadJSReceiver: CCPAConsentViewControllerError {
54+
@objcMembers public class CCPAUnableToLoadJSReceiver: CCPAConsentViewControllerError {
5555
public var failureReason: String? { return "Unable to load the JSReceiver.js resource." }
5656
override public var description: String { return "\(failureReason!)\n" }
5757
}
5858

59-
@objcMembers public class NoInternetConnection: CCPAConsentViewControllerError {
59+
@objcMembers public class CCPANoInternetConnection: CCPAConsentViewControllerError {
6060
public var failureReason: String? { return "The device is not connected to the internet." }
6161
override public var description: String { return "\(failureReason!)\n" }
6262
}
6363

64-
@objcMembers public class MessageEventParsingError: CCPAConsentViewControllerError {
64+
@objcMembers public class CCPAMessageEventParsingError: CCPAConsentViewControllerError {
6565
let message: String
6666

6767
init(message: String) {
@@ -75,12 +75,12 @@ import Foundation
7575
override public var description: String { return "\(failureReason!)\n" }
7676
}
7777

78-
@objcMembers public class WebViewError: CCPAConsentViewControllerError {
78+
@objcMembers public class CCPAWebViewError: CCPAConsentViewControllerError {
7979
public var failureReason: String? { return "Something went wrong in the webview" }
8080
override public var description: String { return "\(failureReason!)\n" }
8181
}
8282

83-
@objcMembers public class URLParsingError: CCPAConsentViewControllerError {
83+
@objcMembers public class CCPAURLParsingError: CCPAConsentViewControllerError {
8484
let urlString: String
8585

8686
init(urlString: String) {
@@ -94,7 +94,7 @@ import Foundation
9494
override public var description: String { return "\(failureReason!)\n" }
9595
}
9696

97-
@objcMembers public class InvalidArgumentError: CCPAConsentViewControllerError {
97+
@objcMembers public class CCPAInvalidArgumentError: CCPAConsentViewControllerError {
9898
let message: String
9999

100100
init(message: String) {

CCPAConsentViewController/Classes/ConsentDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ import Foundation
4444
@objc optional func onConsentReady(consentUUID: ConsentUUID, userConsent: UserConsent)
4545

4646
/// the `onError` function can be called at any moment during the SDKs lifecycle
47-
@objc optional func onError(error: CCPAConsentViewControllerError?)
47+
@objc optional func onError(ccpaError: CCPAConsentViewControllerError?)
4848
}

CCPAConsentViewController/Classes/MessageWebViewController.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MessageWebViewController: MessageViewController, WKUIDelegate, WKNavigatio
2222
guard let scriptSource = try? String(
2323
contentsOfFile: Bundle(for: CCPAConsentViewController.self).path(forResource: MessageWebViewController.MESSAGE_HANDLER_NAME, ofType: "js")!)
2424
else {
25-
consentDelegate?.onError?(error: UnableToLoadJSReceiver())
25+
consentDelegate?.onError?(ccpaError: CCPAUnableToLoadJSReceiver())
2626
return nil
2727
}
2828
let script = WKUserScript(source: scriptSource, injectionTime: .atDocumentStart, forMainFrameOnly: true)
@@ -104,7 +104,7 @@ class MessageWebViewController: MessageViewController, WKUIDelegate, WKNavigatio
104104
}
105105

106106
func onError(error: CCPAConsentViewControllerError?) {
107-
consentDelegate?.onError?(error: error)
107+
consentDelegate?.onError?(ccpaError: error)
108108
closeConsentUIIfOpen()
109109
}
110110

@@ -147,7 +147,7 @@ class MessageWebViewController: MessageViewController, WKUIDelegate, WKNavigatio
147147
if connectvityManager.isConnectedToNetwork() {
148148
webview?.load(URLRequest(url: url))
149149
} else {
150-
onError(error: NoInternetConnection())
150+
onError(error: CCPANoInternetConnection())
151151
}
152152
}
153153

@@ -162,7 +162,7 @@ class MessageWebViewController: MessageViewController, WKUIDelegate, WKNavigatio
162162

163163
override func loadPrivacyManager() {
164164
guard let url = pmUrl() else {
165-
onError(error: URLParsingError(urlString: "PMUrl"))
165+
onError(error: CCPAURLParsingError(urlString: "PMUrl"))
166166
return
167167
}
168168
load(url: url)
@@ -207,7 +207,7 @@ class MessageWebViewController: MessageViewController, WKUIDelegate, WKNavigatio
207207
let body = message.body as? [String: Any?],
208208
let name = body["name"] as? String
209209
else {
210-
onError(error: MessageEventParsingError(message: Optional(message.body).debugDescription))
210+
onError(error: CCPAMessageEventParsingError(message: Optional(message.body).debugDescription))
211211
return
212212
}
213213

@@ -222,12 +222,12 @@ class MessageWebViewController: MessageViewController, WKUIDelegate, WKNavigatio
222222
let actionType = payload["type"] as? Int,
223223
let action = Action(rawValue: actionType)
224224
else {
225-
onError(error: MessageEventParsingError(message: Optional(message.body).debugDescription))
225+
onError(error: CCPAMessageEventParsingError(message: Optional(message.body).debugDescription))
226226
return
227227
}
228228
onAction(action, consents: getPMConsentsIfAny(payload))
229229
case "onError":
230-
onError(error: WebViewError())
230+
onError(error: CCPAWebViewError())
231231
default:
232232
print(message.body)
233233
}

CCPAConsentViewController/Classes/PropertyName.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Foundation
1717
private static func validate(_ string: String) throws -> String {
1818
let regex = try NSRegularExpression(pattern: validPattern, options: [])
1919
if regex.matches(in: string, options: [], range: NSRange(location: 0, length: string.count)).isEmpty {
20-
throw InvalidArgumentError(message: "PropertyName can only include letters, numbers, '.', ':', '-' and '/'. \(string) passed is invalid")
20+
throw CCPAInvalidArgumentError(message: "PropertyName can only include letters, numbers, '.', ':', '-' and '/'. \(string) passed is invalid")
2121
} else {
2222
return string
2323
}

CCPAConsentViewController/Classes/SourcePointClient/SimpleClient.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class SimpleClient: HttpClient {
8585
func request(_ urlRequest: URLRequest, _ completionHandler: @escaping CompletionHandler) {
8686
logRequest(urlRequest, urlRequest.httpBody)
8787
guard connectivityManager.isConnectedToNetwork() else {
88-
completionHandler(nil, NoInternetConnection())
88+
completionHandler(nil, CCPANoInternetConnection())
8989
return
9090
}
9191
session.configuration.requestCachePolicy = .reloadIgnoringLocalCacheData
@@ -94,14 +94,14 @@ class SimpleClient: HttpClient {
9494
self?.logResponse(urlRequest, data)
9595
data != nil ?
9696
completionHandler(data, nil) :
97-
completionHandler(nil, GeneralRequestError(urlRequest.url, response, error))
97+
completionHandler(nil, CCPAGeneralRequestError(urlRequest.url, response, error))
9898
}
9999
}.resume()
100100
}
101101

102102
func post(url: URL?, body: Data?, completionHandler: @escaping CompletionHandler) {
103103
guard let _url = url else {
104-
completionHandler(nil, GeneralRequestError(url, nil, nil))
104+
completionHandler(nil, CCPAGeneralRequestError(url, nil, nil))
105105
return
106106
}
107107
var urlRequest = URLRequest(url: _url)
@@ -113,7 +113,7 @@ class SimpleClient: HttpClient {
113113

114114
func get(url: URL?, completionHandler: @escaping CompletionHandler) {
115115
guard let _url = url else {
116-
completionHandler(nil, GeneralRequestError(url, nil, nil))
116+
completionHandler(nil, CCPAGeneralRequestError(url, nil, nil))
117117
return
118118
}
119119
request(URLRequest(url: _url), completionHandler)

CCPAConsentViewController/Classes/SourcePointClient/SourcePointClient.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class SourcePointClient {
8787
return components?.url
8888
}
8989

90-
func getMessage(consentUUID: ConsentUUID, authId: String?, completionHandler: @escaping (MessageResponse?, APIParsingError?) -> Void) {
90+
func getMessage(consentUUID: ConsentUUID, authId: String?, completionHandler: @escaping (MessageResponse?, CCPAAPIParsingError?) -> Void) {
9191
let url = getMessageUrl(consentUUID, propertyName: propertyName, authId: authId)
9292
client.get(url: url) { [weak self] data, error in
9393
do {
@@ -96,10 +96,10 @@ class SourcePointClient {
9696
UserDefaults.standard.setValue(messageResponse?.meta, forKey: CCPAConsentViewController.META_KEY)
9797
completionHandler(messageResponse, nil)
9898
} else {
99-
completionHandler(nil, APIParsingError(url?.absoluteString ?? "getMessage", error))
99+
completionHandler(nil, CCPAAPIParsingError(url?.absoluteString ?? "getMessage", error))
100100
}
101101
} catch {
102-
completionHandler(nil, APIParsingError(url?.absoluteString ?? "getMessage", error))
102+
completionHandler(nil, CCPAAPIParsingError(url?.absoluteString ?? "getMessage", error))
103103
}
104104
}
105105
}
@@ -111,7 +111,7 @@ class SourcePointClient {
111111
)
112112
}
113113

114-
func postAction(action: Action, consentUUID: ConsentUUID, consents: PMConsents?, completionHandler: @escaping (ActionResponse?, APIParsingError?) -> Void) {
114+
func postAction(action: Action, consentUUID: ConsentUUID, consents: PMConsents?, completionHandler: @escaping (ActionResponse?, CCPAAPIParsingError?) -> Void) {
115115
let url = postActionUrl(action.rawValue)
116116
let meta = UserDefaults.standard.string(forKey: CCPAConsentViewController.META_KEY) ?? "{}"
117117
let ccpaConsents = CPPAPMConsents(rejectedVendors: consents?.vendors.rejected ?? [], rejectedCategories: consents?.categories.rejected ?? [])
@@ -124,7 +124,7 @@ class SourcePointClient {
124124
consents: ccpaConsents,
125125
meta: meta
126126
)) else {
127-
completionHandler(nil, APIParsingError(url?.absoluteString ?? "POST consent", nil))
127+
completionHandler(nil, CCPAAPIParsingError(url?.absoluteString ?? "POST consent", nil))
128128
return
129129
}
130130

@@ -135,10 +135,10 @@ class SourcePointClient {
135135
UserDefaults.standard.setValue(actionResponse?.meta, forKey: CCPAConsentViewController.META_KEY)
136136
completionHandler(actionResponse, nil)
137137
} else {
138-
completionHandler(nil, APIParsingError(url?.absoluteString ?? "POST consent", error))
138+
completionHandler(nil, CCPAAPIParsingError(url?.absoluteString ?? "POST consent", error))
139139
}
140140
} catch {
141-
completionHandler(nil, APIParsingError(url?.absoluteString ?? "POST consent", error))
141+
completionHandler(nil, CCPAAPIParsingError(url?.absoluteString ?? "POST consent", error))
142142
}
143143
}
144144
}

CCPAConsentViewController/Classes/UserConsent.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public typealias SPUsPrivacyString = String
108108
case "rejectedSome": status = .RejectedSome
109109
case "rejectedAll": status = .RejectedAll
110110
case "consentedAll": status = .ConsentedAll
111-
default: throw MessageEventParsingError(message: "Unknown status string: \(statusString)")
111+
default: throw CCPAMessageEventParsingError(message: "Unknown status string: \(statusString)")
112112
}
113113
}
114114
}

CHANGELOG.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
## 1.4.0 (Nov, 07, 2020)
2+
* Prefixed error classes with `CCPA` to avoid class naming clashes with the GDPR SDK [#50](https://github.com/SourcePointUSA/CCPA_iOS_SDK/pull/50)
3+
* Fixed an issue with authenticated consent not clearing user data when authId changed [#54](https://github.com/SourcePointUSA/CCPA_iOS_SDK/pull/54)
4+
* Significantly improved end-to-end testing
5+
6+
## 1.3.3 (Oct, 09, 2020)
7+
* Fixed an issue that was causing clash between GeneralRequestError class in GDPR and CCPA SDKs [#50](https://github.com/SourcePointUSA/CCPA_iOS_SDK/pull/50).
8+
## 1.3.2 (Sept, 29, 2020)
9+
* Fixed an issue that was causing clash between onError methods in GDPR and CCPA SDKs [#48](https://github.com/SourcePointUSA/CCPA_iOS_SDK/pull/48).
110
## 1.3.1 (Aug, 13, 2020)
2-
* Fix an issue that'd prevent the `onAction` delegate method from being called #47
3-
* Implement `.description` to `Action` class #46
4-
* Make sure `onConsentReady` is called on all actions that closes the ConsentUI #41
5-
11+
* Fix an issue that'd prevent the onAction delegate method from being called [#47](https://github.com/SourcePointUSA/CCPA_iOS_SDK/pull/47).
12+
* Implement .description to Action class [#46](https://github.com/SourcePointUSA/CCPA_iOS_SDK/pull/46).
13+
* Make sure onConsentReady is called on all actions that closes the ConsentUI [#41](https://github.com/SourcePointUSA/CCPA_iOS_SDK/pull/41).
614
## 1.3.0 (Jun, 12, 2020)
715
* Store the `IABUSPrivacy_String` as spec'ed by the [CCPA IAB](https://github.com/InteractiveAdvertisingBureau/USPrivacy/blob/master/CCPA/USP%20API.md#in-app-support).
816
* Store the "ccpa applies" boolean. This is not covered by the IAB CCPA In-app spec so we're using our own key. It can be retrieved by reading it from the `UserDefaults` with:

0 commit comments

Comments
 (0)