Skip to content

Commit

Permalink
Merge pull request #28 from AppSci/0.0.50
Browse files Browse the repository at this point in the history
0.0.50
  • Loading branch information
andrew-skrypnyk authored Mar 22, 2021
2 parents 396ae3f + 47589e8 commit 237d946
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 40 deletions.
2 changes: 1 addition & 1 deletion PandaSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions Sources/PandaSDK/ConfiguredPanda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()})
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Sources/PandaSDK/Extension+StoreKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/PandaSDK/NetworkClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func retry<T>(_ 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)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/PandaSDK/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
Expand Down
2 changes: 1 addition & 1 deletion Sources/PandaSDK/SubsriptionStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 9 additions & 7 deletions Sources/PandaSDK/UnconfiguredPanda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(\"<API_TOKEN>\") and wait, until you get `callback(true)`"

struct LastConfigurationAttempt {
var apiKey: String
Expand Down Expand Up @@ -78,16 +80,16 @@ final class UnconfiguredPanda: PandaProtocol, ObserverSupport {
}

func prefetchScreen(screenId: String?) {
pandaLog("Please, configure Panda, by calling Panda.configure(\"<API_TOKEN>\")")
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<Bool, Error>) -> Void)? = nil) {
pandaLog("Please, configure Panda, by calling Panda.configure(\"<API_TOKEN>\")")
pandaLog(UnconfiguredPanda.configError)
onShow?(.failure(Errors.notConfigured))
}

func getSubscriptionStatus(statusCallback: ((Result<SubscriptionStatus, Error>) -> Void)?) {
pandaLog("Please, configure Panda, by calling Panda.configure(\"<API_TOKEN>\")")
pandaLog(UnconfiguredPanda.configError)
statusCallback?(.failure(Errors.notConfigured))
}

Expand All @@ -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(\"<API_TOKEN>\")")
pandaLog(UnconfiguredPanda.configError)
}

private func prepareViewController(screenData: ScreenData) -> WebViewController {
Expand Down Expand Up @@ -213,16 +215,16 @@ final class UnconfiguredPanda: PandaProtocol, ObserverSupport {
}

public func verifySubscriptions(callback: @escaping (Result<ReceiptVerificationResult, Error>) -> Void) {
pandaLog("Please, configure Panda, by calling Panda.configure(\"<API_TOKEN>\")")
pandaLog(UnconfiguredPanda.configError)
callback(.failure(Errors.notConfigured))
}

func purchase(productID: String) {
pandaLog("Please, configure Panda, by calling Panda.configure(\"<API_TOKEN>\")")
pandaLog(UnconfiguredPanda.configError)
}

func restorePurchase() {
pandaLog("Please, configure Panda, by calling Panda.configure(\"<API_TOKEN>\")")
pandaLog(UnconfiguredPanda.configError)
}

func setCustomUserId(id: String) {
Expand Down
24 changes: 3 additions & 21 deletions Sources/PandaSDK/Views/WebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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() {
Expand All @@ -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)")
}
}
}
Expand Down

0 comments on commit 237d946

Please sign in to comment.