Skip to content

Commit

Permalink
docs: updates to documentation to cover the real time flags updates f…
Browse files Browse the repository at this point in the history
…or iOS (#4718)
  • Loading branch information
gazreese authored Oct 28, 2024
1 parent 6bbd6c7 commit a9dd41f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
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
}
```

0 comments on commit a9dd41f

Please sign in to comment.