Skip to content

Commit

Permalink
docs: Getting flags by identity - iOS (#4010)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackforesightmobile authored May 24, 2024
1 parent 6f321d4 commit 1ae51a4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/docs/clients/client-side/ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down

0 comments on commit 1ae51a4

Please sign in to comment.