Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Getting flags by identity - iOS #4010

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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