Skip to content

Commit

Permalink
Update samples
Browse files Browse the repository at this point in the history
  • Loading branch information
z4kn4fein committed Oct 14, 2022
1 parent 930a092 commit 3ef0608
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
1 change: 1 addition & 0 deletions Sources/ConfigCat/ConfigService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ class ConfigService {
guard let this = self else {
return
}
this.log.debug(message: "Polling for config.json changes.")
this.fetchIfOlder(time: Date().subtract(seconds: ageThreshold)!) { _ in
// we don't have to do anything with the result in the timer ticks.
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ConfigCat/RolloutEvaluator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class RolloutEvaluator {
for rule in setting.percentageItems {
bucket += rule.percentage
if scaled < bucket {
evaluateLog += "\n" + String(format: "Evaluating %% options. Returning %@", rule.value as? String ?? "")
evaluateLog += "\n" + String(format: "Evaluating %@ options. Returning %@", "%", rule.value as? String ?? "")
return (rule.value, rule.variationId, evaluateLog, nil, rule)
}
}
Expand Down
6 changes: 3 additions & 3 deletions samples/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- ConfigCat (9.0.1)
- ConfigCat (9.1.0)

DEPENDENCIES:
- ConfigCat (from `https://github.com/configcat/swift-sdk.git`, branch `master`)
Expand All @@ -11,11 +11,11 @@ EXTERNAL SOURCES:

CHECKOUT OPTIONS:
ConfigCat:
:commit: 24d844be9a92597bccdfbdf233ca4c25491b2254
:commit: 930a092714a221dff28ffd8dc6e2429e04675f9c
:git: https://github.com/configcat/swift-sdk.git

SPEC CHECKSUMS:
ConfigCat: 5343cbf7703c9e50506a528d0974876d7ec24ef5
ConfigCat: 4c01960d968c6505f35b29770e9ba603ad6252af

PODFILE CHECKSUM: 9be1ab171ff7511f957624c62897daa13dae8e46

Expand Down
18 changes: 11 additions & 7 deletions samples/ios/configcatsample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@ import ConfigCat
class ViewController: UIViewController {

var client: ConfigCatClient?
var user: ConfigCatUser?
@IBOutlet weak var label: UILabel!

override func viewDidLoad() {
super.viewDidLoad()
let options = ClientOptions.default

let mode = PollingModes.autoPoll(autoPollIntervalInSeconds: 5) {
options.refreshMode = PollingModes.autoPoll(autoPollIntervalInSeconds: 5)
options.hooks.addOnConfigChanged { _ in
self.configChanged()
}

// Info level logging helps to inspect the feature flag evaluation process.
// Remove this line to avoid too detailed logging in your application.
options.logLevel = .info

// Creating a user object to identify your user (optional).
self.user = ConfigCatUser(identifier: "user-id", email: "[email protected]")
options.defaultUser = ConfigCatUser(identifier: "user-id", email: "[email protected]")

self.client = ConfigCatClient(
self.client = ConfigCatClient.get(
sdkKey: "PKDVCLf-Hq-h-kCzMp-L7Q/psuH7BGHoUmdONrzzUOY7A",
refreshMode: mode,
logLevel: .info // Info level logging helps to inspect the feature flag evaluation process. Remove this line to avoid too detailed logging in your application.
options: options
)
}

Expand All @@ -30,7 +34,7 @@ class ViewController: UIViewController {
}

func configChanged() {
self.client?.getValue(for: "string25Cat25Dog25Falcon25Horse", defaultValue: "", user: self.user) { value in
self.client?.getValue(for: "string25Cat25Dog25Falcon25Horse", defaultValue: "") { value in
DispatchQueue.main.sync {
self.label.text = value
}
Expand Down
6 changes: 3 additions & 3 deletions samples/osx/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- ConfigCat (9.0.1)
- ConfigCat (9.1.0)

DEPENDENCIES:
- ConfigCat (from `https://github.com/configcat/swift-sdk.git`, branch `master`)
Expand All @@ -11,11 +11,11 @@ EXTERNAL SOURCES:

CHECKOUT OPTIONS:
ConfigCat:
:commit: 24d844be9a92597bccdfbdf233ca4c25491b2254
:commit: 930a092714a221dff28ffd8dc6e2429e04675f9c
:git: https://github.com/configcat/swift-sdk.git

SPEC CHECKSUMS:
ConfigCat: 5343cbf7703c9e50506a528d0974876d7ec24ef5
ConfigCat: 4c01960d968c6505f35b29770e9ba603ad6252af

PODFILE CHECKSUM: cefb5b755aab5575d8660d2128a13614655fe285

Expand Down
18 changes: 8 additions & 10 deletions samples/osx/configcatsample-objc/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@

int main(int argc, const char * argv[]) {
@autoreleasepool {
// Initialize the ConfigCatClient with an SDK Key.
ClientOptions* options = [ClientOptions default];

// Info level logging helps to inspect the feature flag evaluation process.
// Use the default Warning level to avoid too detailed logging in your application.
ConfigCatClient* client = [[ConfigCatClient alloc]initWithSdkKey:@"PKDVCLf-Hq-h-kCzMp-L7Q/HhOWfwVtZ0mb30i9wi17GQ"
dataGovernance:DataGovernanceGlobal
configCache:nil
refreshMode:nil
sessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]
baseUrl:@""
flagOverrides:nil
logLevel:LogLevelInfo];

options.logLevel = LogLevelInfo;

// Initialize the ConfigCatClient with an SDK Key.
ConfigCatClient* client = [ConfigCatClient getWithSdkKey:@"PKDVCLf-Hq-h-kCzMp-L7Q/HhOWfwVtZ0mb30i9wi17GQ"
options:options];

// Creating a user object to identify your user (optional).
ConfigCatUser* userObject = [[ConfigCatUser alloc]initWithIdentifier:@"Some UserID"
email:@"[email protected]"
Expand Down

0 comments on commit 3ef0608

Please sign in to comment.