diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 5c11922..fd4243e 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,13 +1,13 @@ PODS: - - Alamofire (5.2.2) - - Kingfisher (5.15.2): - - Kingfisher/Core (= 5.15.2) - - Kingfisher/Core (5.15.2) - - PlutoSDK/Core (0.8.3): + - Alamofire (5.3.0) + - Kingfisher (5.15.6): + - Kingfisher/Core (= 5.15.6) + - Kingfisher/Core (5.15.6) + - PlutoSDK/Core (0.8.4): - Alamofire (~> 5) - SwiftyJSON (~> 5) - SwiftyUserDefaults (~> 5) - - PlutoSDK/Rx (0.8.3): + - PlutoSDK/Rx (0.8.4): - PlutoSDK/Core (~> 0) - RxCocoa (~> 5) - RxCocoa (5.1.1): @@ -38,9 +38,9 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - Alamofire: 814429acc853c6c54ff123fc3d2ef66803823ce0 - Kingfisher: 1f60394409c6b916ce31474bcf73fdde6f3b9a7b - PlutoSDK: 0b10a6d9c0289f0cecc6169d592a258cf4443eb7 + Alamofire: 2c792affbdc2f18016e08fdbcacd60aebe1ba593 + Kingfisher: b3554e7bf6106115b44e8795300bad580ef2fdc7 + PlutoSDK: 4d156962bbd58309a9eb2652bb7b3368caf4e082 RxCocoa: 32065309a38d29b5b0db858819b5bf9ef038b601 RxRelay: d77f7d771495f43c556cbc43eebd1bb54d01e8e9 RxSwift: 81470a2074fa8780320ea5fe4102807cb7118178 diff --git a/Pluto/Classes/Core/Defaults.swift b/Pluto/Classes/Core/Defaults.swift index d5bf9dd..17a40eb 100644 --- a/Pluto/Classes/Core/Defaults.swift +++ b/Pluto/Classes/Core/Defaults.swift @@ -106,7 +106,10 @@ class DefaultsManager { ) } ) - + } + + var isTokenNil: Bool { + accessToken == nil || refreshToken == nil } func updateAccessToken(_ accessToken: String) -> Bool { @@ -132,5 +135,5 @@ class DefaultsManager { sub = nil infoJSONString = nil } - + } diff --git a/Pluto/Classes/Core/Pluto.swift b/Pluto/Classes/Core/Pluto.swift index 22dc657..91f7d8f 100644 --- a/Pluto/Classes/Core/Pluto.swift +++ b/Pluto/Classes/Core/Pluto.swift @@ -44,7 +44,7 @@ final public class Pluto { var isWeChatInstalled = false var stateObserver: ((State) -> Void)? - var state: State = .loading { + var state: State = DefaultsManager.shared.isTokenNil ? .notSignin : .signin { didSet { stateObserver?(state) } @@ -82,14 +82,6 @@ final public class Pluto { self.server = server self.appId = appId self.isWeChatInstalled = isWeChatInstalled - - getAccessToken { [unowned self] in - guard $0 != nil else { - self.state = .notSignin - return - } - self.state = .signin - } } public func observeState(observer: ((State) -> Void)?) { diff --git a/PlutoSDK.podspec b/PlutoSDK.podspec index 19dcdcb..2c7e908 100644 --- a/PlutoSDK.podspec +++ b/PlutoSDK.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'PlutoSDK' - s.version = '0.8.3' + s.version = '0.8.4' s.summary = 'Swift SDK for Pluto login microservice.' # This description is used to generate tags and improve search results.