Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Commit

Permalink
release 0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Elaz committed Jun 17, 2019
1 parent ce1bd26 commit 929d92a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 13 deletions.
4 changes: 2 additions & 2 deletions KinEcosystem.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'KinEcosystem'
s.version = '0.9.0'
s.version = '0.9.1'
s.summary = 'Kin Ecosystem mobile sdk for iOS'
s.description = <<-DESC
Kin ecosystem mobile sdk for iOS
Expand All @@ -11,7 +11,7 @@ Kin ecosystem mobile sdk for iOS
s.author = { 'Kin' => '[email protected]' }
s.source = { :git => 'https://github.com/kinfoundation/kin-ecosystem-ios-sdk.git', :tag => s.version.to_s }

s.ios.deployment_target = '8.1'
s.ios.deployment_target = '9.0'
s.resource_bundle = { "kinLocalization" => ["KinEcosystem/*.lproj/*.strings"] }
s.source_files = 'KinEcosystem/**/*.{h,m,swift}'
s.resources = 'KinEcosystem/**/*.{xcassets,xcdatamodeld,storyboard,xib,png,pdf,jpg,json,strings}'
Expand Down
47 changes: 36 additions & 11 deletions KinEcosystem/Core/Kin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import StellarErrors
import KinUtil
import KinMigrationModule

let SDKVersion = "0.9.0"
let SDKVersion = "0.9.1"

public typealias KinUserStatsCallback = (UserStats?, Error?) -> ()
public typealias KinLoginCallback = (Error?) -> ()
Expand Down Expand Up @@ -72,6 +72,9 @@ public class Kin {
fileprivate var nativeOffersInc:Int32 = -1
fileprivate var brManager:BRManager?

// a temporary workaround to StellarKit.TransactionError.txBAD_SEQ
fileprivate let purchaseQueue = OperationQueue()

public var lastKnownBalance: Balance? {
return core?.blockchain.lastBalance ?? nil
}
Expand All @@ -95,6 +98,16 @@ public class Kin {
}
}

init() {
purchaseQueue.maxConcurrentOperationCount = 1
NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: nil) { _ in
self.purchaseQueue.isSuspended = true
}
NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification, object: nil, queue: nil) { _ in
self.purchaseQueue.isSuspended = false
}
}

public func start(environment: Environment) throws {
guard core == nil else {
return
Expand Down Expand Up @@ -377,19 +390,31 @@ public class Kin {
return false
}
defer {
_ = attemptEx(2, closure: { attemptNum -> Promise<String> in
return core.onboard()
.then {
Flows.nativeSpend(jwt: offerJWT, core: core)
// a temporary workaround to StellarKit.TransactionError.txBAD_SEQ
purchaseQueue.addOperation {
let group = DispatchGroup()
group.enter()
let attempt = attemptEx(2, closure: { attemptNum -> Promise<String> in
return core.onboard()
.then {
Flows.nativeSpend(jwt: offerJWT, core: core)
}
}) { error in
self.recoverByMigratingIfNeeded(from: error)
}.then { jwt in
completion(jwt, nil)
}.error { error in
completion(nil, KinEcosystemError.transform(error))
}
}) { error in
self.recoverByMigratingIfNeeded(from: error)
}.then { jwt in
completion(jwt, nil)
}.error { error in
completion(nil, KinEcosystemError.transform(error))
attempt.finally {
group.leave()
}
group.wait()
}


}
return true
}
Expand Down

0 comments on commit 929d92a

Please sign in to comment.