-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Getting flags by identity - iOS (#4010)
- Loading branch information
1 parent
6f321d4
commit 1ae51a4
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,36 @@ Flagsmith.shared.getTraits(forIdentity: "[email protected]") {(result) in | |
} | ||
``` | ||
|
||
To retrieve a flag for a particular identity: | ||
|
||
```swift | ||
Flagsmith.shared.getFeatureFlags(forIdentity: "[email protected]") {(result) in | ||
switch result { | ||
case .success(let flags): | ||
for flag in flags { | ||
let name = flag.feature.name | ||
let value = flag.value?.stringValue | ||
let enabled = flag.enabled | ||
print(name, "= enabled:", enabled, "value:", value ?? "nil") | ||
} | ||
case .failure(let error): | ||
print(error) | ||
} | ||
} | ||
``` | ||
|
||
If you would prefer to do this using async/await you can do the following: | ||
|
||
```swift | ||
let flags = try await Flagsmith.shared.getFeatureFlags(forIdentity: "[email protected]") | ||
for flag in flags { | ||
let name = flag.feature.name | ||
let value = flag.value?.stringValue | ||
let enabled = flag.enabled | ||
print(name, "= enabled:", enabled, "value:", value ?? "nil") | ||
} | ||
``` | ||
|
||
## Override Default Configuration | ||
|
||
In `AppDelegate.swift`: | ||
|