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: updates to documentation to cover the real time flags updates for iOS #4718

Merged
Merged
Changes from 1 commit
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
33 changes: 29 additions & 4 deletions docs/docs/clients/client-side/ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import FlagsmithClient
```swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

Flagsmith.shared.apiKey = "<YOUR_API_KEY>"
Flagsmith.shared.apiKey = "<YOUR_ENVIRONMENT_KEY>"
// The rest of your launch method code
}
```
Expand Down Expand Up @@ -286,6 +286,30 @@ If more customisation is required, you can override the cache implemention with
Flagsmith.shared.cacheConfig.cache = <CUSTOM_CACHE_IMPLEMENTATION>
```

### Real Time Updates

By default real-time updates are disabled. When enabled the SDK will listen for changes to flags and update the cache as needed. If you want to enable real-time updates you can do so by setting the following flag:

```swift
Flagsmith.shared.enableRealTimeUpdates = false
```

It's possible to listen to updates in real time from the SDK using the `flagStream` property.

```swift
func subscribeToFlagUpdates() {
Task {
for await updatedFlags in flagsmith.flagStream {
DispatchQueue.main.async {
flags = updatedFlags
}
}
}
}
```

You can find an example of this functionality in the Flagsmith iOS Example app, which should work on your own data if you replace your Environment Key in the `AppDelegate.swift` file.

## Override default configuration

By default, the client uses a default configuration. You can override the configuration as follows:
Expand All @@ -295,8 +319,9 @@ Override just the default API URI with your own:
```swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

Flagsmith.shared.apiKey = "<YOUR_API_KEY>"
Flagsmith.shared.baseURL = "https://<your-self-hosted-api>/api/v1/"
// The rest of your launch method code
Flagsmith.shared.apiKey = "<YOUR_API_KEY>"
Flagsmith.shared.baseURL = "https://<your-self-hosted-api>/api/v1/"
Flagsmith.eventSourceBaseURL = "https://<your-self-hosted-api>/api/v1/"
// The rest of your launch method code
}
```
Loading