diff --git a/PandaSDK.podspec b/PandaSDK.podspec index 484dd41..2639f87 100644 --- a/PandaSDK.podspec +++ b/PandaSDK.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |spec| # spec.name = "PandaSDK" - spec.version = "0.0.49" + spec.version = "0.0.50" spec.summary = "Panda pod which will help us boost our revenue." # This description is used to generate tags and improve search results. diff --git a/Sources/PandaSDK/ConfiguredPanda.swift b/Sources/PandaSDK/ConfiguredPanda.swift index 1e19a94..26fab6e 100644 --- a/Sources/PandaSDK/ConfiguredPanda.swift +++ b/Sources/PandaSDK/ConfiguredPanda.swift @@ -105,7 +105,7 @@ final public class Panda: PandaProtocol, ObserverSupport { } case .success(let verification): - print("productId = \(productId)\nid = \(verification.id)") + pandaLog("productId = \(productId)\nid = \(verification.id)") DispatchQueue.main.async { self?.viewControllers.forEach { $0.value?.onFinishLoad() } self?.viewControllers.forEach({ $0.value?.tryAutoDismiss()}) @@ -474,7 +474,7 @@ final public class Panda: PandaProtocol, ObserverSupport { public func setCustomUserId(id: String) { var device = deviceStorage.fetch() ?? DeviceSettings.default guard device.customUserId != id else { - print("Already sent custom user id") + pandaLog("Already sent custom user id") return } device.customUserId = id @@ -492,7 +492,7 @@ final public class Panda: PandaProtocol, ObserverSupport { public func registerDevice(token: Data) { var device = deviceStorage.fetch() ?? DeviceSettings.default guard device.pushToken != token.hexString() else { - print("Already sent apnsToken") + pandaLog("Already sent apnsToken") return } device.pushToken = token.hexString() @@ -510,7 +510,7 @@ final public class Panda: PandaProtocol, ObserverSupport { public func registerAppsFlyer(id: String) { var device = deviceStorage.fetch() ?? DeviceSettings.default guard device.appsFlyerId != id else { - print("Already sent apnsToken") + pandaLog("Already sent apnsToken") return } device.appsFlyerId = id @@ -528,7 +528,7 @@ final public class Panda: PandaProtocol, ObserverSupport { public func registerIDFA(id: String) { var device = deviceStorage.fetch() ?? DeviceSettings.default guard device.advertisementIdentifier != id else { - print("Already sent advertisementIdentifier") + pandaLog("Already sent advertisementIdentifier") return } device.advertisementIdentifier = id diff --git a/Sources/PandaSDK/Extension+StoreKit.swift b/Sources/PandaSDK/Extension+StoreKit.swift index 22cc592..975d2e3 100644 --- a/Sources/PandaSDK/Extension+StoreKit.swift +++ b/Sources/PandaSDK/Extension+StoreKit.swift @@ -40,12 +40,12 @@ extension SKProduct { } guard #available(iOS 12.2, *) else { - print("Minimum iOS 12.2 required for offerID [\(offer)] at product [\(productIdentifier)]") + pandaLog("Minimum iOS 12.2 required for offerID [\(offer)] at product [\(productIdentifier)]") return "" } guard let discount = discounts.first(where: {$0.identifier == offerID!}) else { - print("Couldn't find [\(offer)] at [\(productIdentifier)]") + pandaLog("Couldn't find [\(offer)] at [\(productIdentifier)]") return "" } diff --git a/Sources/PandaSDK/NetworkClient.swift b/Sources/PandaSDK/NetworkClient.swift index 65d138a..30e6809 100644 --- a/Sources/PandaSDK/NetworkClient.swift +++ b/Sources/PandaSDK/NetworkClient.swift @@ -297,7 +297,7 @@ func retry(_ attempts: Int, completion(result) return } - print("retries left \(attempts) and error = \(error)") + pandaLog("retries left \(attempts) and error = \(error)") DispatchQueue.main.asyncAfter(deadline: .now() + interval) { retry(attempts - 1, interval: interval, task: task, completion: completion) } diff --git a/Sources/PandaSDK/Storage.swift b/Sources/PandaSDK/Storage.swift index 4f2dbad..d373989 100644 --- a/Sources/PandaSDK/Storage.swift +++ b/Sources/PandaSDK/Storage.swift @@ -33,14 +33,14 @@ extension StorageProtocol { do { store(try map(value)) } catch { - print("failed to map while storing \(value)") + pandaLog("failed to map while storing \(value)") } }, fetch: { [fetch] in do { return try fetch().map(pullback) } catch { - print("failed to map while reading \(T.self)") + pandaLog("failed to map while reading \(T.self)") return nil } }, diff --git a/Sources/PandaSDK/SubsriptionStatus.swift b/Sources/PandaSDK/SubsriptionStatus.swift index 9156586..e2d4164 100644 --- a/Sources/PandaSDK/SubsriptionStatus.swift +++ b/Sources/PandaSDK/SubsriptionStatus.swift @@ -37,7 +37,7 @@ extension SubscriptionStatusResponse: Decodable { let sequence = stringDictionary?.compactMap { keyValue -> (SubscriptionType, [SubscriptionInfo])? in guard let key = SubscriptionType(rawValue: keyValue.key) else { - print("Unknown key: \(keyValue.key)") + pandaLog("Unknown key: \(keyValue.key)") return nil } return (key, keyValue.value) diff --git a/Sources/PandaSDK/UnconfiguredPanda.swift b/Sources/PandaSDK/UnconfiguredPanda.swift index 4d38b97..30d32ad 100644 --- a/Sources/PandaSDK/UnconfiguredPanda.swift +++ b/Sources/PandaSDK/UnconfiguredPanda.swift @@ -23,6 +23,8 @@ final class UnconfiguredPanda: PandaProtocol, ObserverSupport { var customUserId: String? var appsFlyerId: String? var advertisementId: String? + + private static let configError = "Please, configure Panda, by calling Panda.configure(\"\") and wait, until you get `callback(true)`" struct LastConfigurationAttempt { var apiKey: String @@ -78,16 +80,16 @@ final class UnconfiguredPanda: PandaProtocol, ObserverSupport { } func prefetchScreen(screenId: String?) { - pandaLog("Please, configure Panda, by calling Panda.configure(\"\")") + pandaLog(UnconfiguredPanda.configError) } public func showScreen(screenType: ScreenType, screenId: String? = nil, product: String? = nil, autoDismiss: Bool = true, presentationStyle: UIModalPresentationStyle = .pageSheet, payload: [String: Any]? = nil, onShow: ((Result) -> Void)? = nil) { - pandaLog("Please, configure Panda, by calling Panda.configure(\"\")") + pandaLog(UnconfiguredPanda.configError) onShow?(.failure(Errors.notConfigured)) } func getSubscriptionStatus(statusCallback: ((Result) -> Void)?) { - pandaLog("Please, configure Panda, by calling Panda.configure(\"\")") + pandaLog(UnconfiguredPanda.configError) statusCallback?(.failure(Errors.notConfigured)) } @@ -111,7 +113,7 @@ final class UnconfiguredPanda: PandaProtocol, ObserverSupport { } func handleApplication(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) { - pandaLog("Please, configure Panda, by calling Panda.configure(\"\")") + pandaLog(UnconfiguredPanda.configError) } private func prepareViewController(screenData: ScreenData) -> WebViewController { @@ -213,16 +215,16 @@ final class UnconfiguredPanda: PandaProtocol, ObserverSupport { } public func verifySubscriptions(callback: @escaping (Result) -> Void) { - pandaLog("Please, configure Panda, by calling Panda.configure(\"\")") + pandaLog(UnconfiguredPanda.configError) callback(.failure(Errors.notConfigured)) } func purchase(productID: String) { - pandaLog("Please, configure Panda, by calling Panda.configure(\"\")") + pandaLog(UnconfiguredPanda.configError) } func restorePurchase() { - pandaLog("Please, configure Panda, by calling Panda.configure(\"\")") + pandaLog(UnconfiguredPanda.configError) } func setCustomUserId(id: String) { diff --git a/Sources/PandaSDK/Views/WebViewController.swift b/Sources/PandaSDK/Views/WebViewController.swift index 56ac757..8f9dd19 100644 --- a/Sources/PandaSDK/Views/WebViewController.swift +++ b/Sources/PandaSDK/Views/WebViewController.swift @@ -116,7 +116,7 @@ class WebViewController: UIViewController, WKScriptMessageHandler { _ userContentController: WKUserContentController, didReceive message: WKScriptMessage ) { - print("JavaScript is sending a message \(message)") + pandaLog("JavaScript messageHandler: `\(message.name)` is sending a message:") if message.name == "onPurchase" { if let data = message.body as? [String: String], @@ -134,24 +134,6 @@ class WebViewController: UIViewController, WKScriptMessageHandler { if message.name == "logHandler" { pandaLog("LOG: \(message.body)") } - - if let data = message.body as? [String: String], - let name = data["name"], let email = data["email"] { - showUser(email: email, name: name) - } - } - - private func showUser(email: String, name: String) { - let userDescription = "\(email) \(name)" - let alertController = UIAlertController( - title: "User", - message: userDescription, - preferredStyle: .alert - ) - alertController.addAction( - UIAlertAction(title: "OK", style: .default) - ) - present(alertController, animated: true) } private func setPayload() { @@ -164,10 +146,10 @@ class WebViewController: UIViewController, WKScriptMessageHandler { """ wv.evaluateJavaScript(js) { (result, error) in if let e = error { - print("error: \(e)") + pandaLog("error: \(e)") } if let res = result { - print("payload \(res)") + pandaLog("payload \(res)") } } }