Skip to content

Commit

Permalink
add config enable refresh token feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Arief Nur Putranto committed Jul 27, 2023
1 parent 566c91d commit 5ce8358
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion QiscusCore.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "QiscusCore"
s.version = "1.10.2"
s.version = "1.10.3"
s.summary = "Qiscus Core SDK for iOS"
s.description = <<-DESC
Qiscus SDK for iOS contains Qiscus public Model.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import PackageDescription
let package = Package(
name: "YOUR_PROJECT_NAME",
dependencies: [
.package(url: "https://github.com/qiscus/QiscusCore-iOS.git", from: "1.10.2"),
.package(url: "https://github.com/qiscus/QiscusCore-iOS.git", from: "1.10.3"),
]
)
```
Expand Down
2 changes: 2 additions & 0 deletions Source/QiscusCore/Model/AppConfigModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class AppConfigModel {
public var enableSync : Bool = true
public var enableSyncEvent : Bool = false
public var autoRefreshToken: Bool = true
public var enableRefreshToken: Bool = false

init(json: JSON) {
self.baseURL = json["base_url"].string ?? ""
Expand All @@ -34,5 +35,6 @@ public class AppConfigModel {
self.enableSync = json["enable_sync"].bool ?? true
self.enableSyncEvent = json["enable_sync_event"].bool ?? false
self.autoRefreshToken = json["auto_refresh_token"].bool ?? true
self.enableRefreshToken = json["enable_refresh_token"].bool ?? false
}
}
18 changes: 12 additions & 6 deletions Source/QiscusCore/QiscusCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public class QiscusCore: NSObject {
public static let qiscusCoreVersionNumber:String = "1.10.2"
public static let qiscusCoreVersionNumber:String = "1.10.3"
class var bundle:Bundle{
get{
let podBundle = Bundle(for: QiscusCore.self)
Expand Down Expand Up @@ -98,6 +98,7 @@ public class QiscusCore: NSObject {
public static var enableSync : Bool = true
public static var enableSyncEvent : Bool = false
public static var enableExpiredToken : Bool = true
public static var enableRefreshToken : Bool = false

@available(*, deprecated, message: "will soon become unavailable.")
public static var enableDebugPrint: Bool = false
Expand Down Expand Up @@ -192,6 +193,7 @@ public class QiscusCore: NSObject {
QiscusCore.enableSync = appConfig.enableSync
QiscusCore.enableSyncEvent = appConfig.enableSyncEvent
QiscusCore.enableExpiredToken = appConfig.autoRefreshToken
QiscusCore.enableRefreshToken = appConfig.enableRefreshToken

//check old and new appServer
if let oldConfig = config.server {
Expand Down Expand Up @@ -542,14 +544,18 @@ public class QiscusCore: NSObject {
}

private func flowLogOut(completion: @escaping (QError?) -> Void){
QiscusCore.shared.logout { success in
self.stopQiscusCore()
completion(nil)
} onError: { error in
if QiscusCore.enableRefreshToken == true {
QiscusCore.shared.logout { success in
self.stopQiscusCore()
completion(nil)
} onError: { error in
self.stopQiscusCore()
completion(nil)
}
}else{
self.stopQiscusCore()
completion(nil)
}

}

private func stopQiscusCore(){
Expand Down

0 comments on commit 5ce8358

Please sign in to comment.