Skip to content

Commit

Permalink
fix: example app could not complie
Browse files Browse the repository at this point in the history
  • Loading branch information
duyhungtnn committed Jul 25, 2023
1 parent 67bb694 commit 62a218d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
23 changes: 13 additions & 10 deletions Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,24 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
if let error {
print(error)
}

let client = try? BKTClient.shared
client.updateUserAttributes(attributes: [:])
print("intVariation =", client.intVariation(featureId: "feature-ios-e2e-integer", defaultValue: 0))
print("doubleVariation =", client.doubleVariation(featureId: "feature-ios-e2e-double", defaultValue: 0.0))
print("boolVariation =", client.boolVariation(featureId: "feature-ios-e2e-bool", defaultValue: false))
print("stringVariation =", client.stringVariation(featureId: "feature-ios-e2e-string", defaultValue: "004 not found..."))
print("jsonVariation =", client.jsonVariation(featureId: "feature-ios-e2e-json", defaultValue: [:]))

var client : BKTClient?
do {
try client = BKTClient.shared
} catch {
print(error.localizedDescription)
}
client?.updateUserAttributes(attributes: [:])
print("intVariation =", client?.intVariation(featureId: "feature-ios-e2e-integer", defaultValue: 0) ?? 0)
print("doubleVariation =", client?.doubleVariation(featureId: "feature-ios-e2e-double", defaultValue: 0.0) ?? 0.0)
print("boolVariation =", client?.boolVariation(featureId: "feature-ios-e2e-bool", defaultValue: false) ?? false)
print("stringVariation =", client?.stringVariation(featureId: "feature-ios-e2e-string", defaultValue: "004 not found...") ?? "004 not found...")
print("jsonVariation =", client?.jsonVariation(featureId: "feature-ios-e2e-json", defaultValue: [:]) ?? [:])
DispatchQueue.main.async {
self.setSingleViewController()
}

DispatchQueue.main.async {
let isTabMode = client.boolVariation(featureId: "ios_test_001", defaultValue: false)
let isTabMode = client?.boolVariation(featureId: "ios_test_001", defaultValue: false) ?? false
if isTabMode {
self.setTabBarController()
} else {
Expand Down
18 changes: 15 additions & 3 deletions Example/FirstViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@ import Bucketeer
class FirstViewController: UIViewController {

@IBOutlet weak var messageLabel: UILabel!
var client : BKTClient?

override func viewDidLoad() {
super.viewDidLoad()
do {
try client = BKTClient.shared
} catch {
// We may have an error when we did not initialize the client
// Handle error
}
}

override func viewWillAppear(_ animated: Bool) {
messageLabel.text = BKTClient.shared.stringVariation(featureId: "ios_test_002", defaultValue: "not found...")

let colorCode = BKTClient.shared.stringVariation(featureId: "ios_test_003", defaultValue: "#999999")
messageLabel.text = client?.stringVariation(featureId: "ios_test_002", defaultValue: "not found...") ?? "not found..."

let colorCode = client?.stringVariation(featureId: "ios_test_003", defaultValue: "#999999") ?? "#999999"
view.backgroundColor = UIColor(hex: colorCode)
}
@IBAction func trackButtonAction(_ sender: Any) {
BKTClient.shared.track(goalId: "ios_test_002", value: 1)
client?.track(goalId: "ios_test_002", value: 1)
}
}

Expand Down

0 comments on commit 62a218d

Please sign in to comment.