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
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ local IP.
npm run start -- --host 0.0.0.0
```

### Checking your changes with prettier

After you make changes to the documentation, you can check the changes by running the following command:

```console
npx prettier --check docs
```

If you want to apply any fixes discovered, you can run the following command:

```console
npx prettier <YOUR_DOC> --write
```

## Build

```console
Expand Down
35 changes: 31 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,32 @@ 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 +321,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
}
```