From d044eb827299430f47a17c6c9454d536fd345ba1 Mon Sep 17 00:00:00 2001 From: Gareth Reese Date: Thu, 10 Oct 2024 10:19:33 +0100 Subject: [PATCH 1/2] Updates to documentation to cover the real time flags updates for iOS --- docs/docs/clients/client-side/ios.md | 33 ++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/docs/docs/clients/client-side/ios.md b/docs/docs/clients/client-side/ios.md index fb5efc016e0e..82d4af0a6ca8 100644 --- a/docs/docs/clients/client-side/ios.md +++ b/docs/docs/clients/client-side/ios.md @@ -47,7 +47,7 @@ import FlagsmithClient ```swift func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { -Flagsmith.shared.apiKey = "" +Flagsmith.shared.apiKey = "" // The rest of your launch method code } ``` @@ -286,6 +286,30 @@ If more customisation is required, you can override the cache implemention with Flagsmith.shared.cacheConfig.cache = ``` +### 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: @@ -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 = "" -Flagsmith.shared.baseURL = "https:///api/v1/" -// The rest of your launch method code + Flagsmith.shared.apiKey = "" + Flagsmith.shared.baseURL = "https:///api/v1/" + Flagsmith.eventSourceBaseURL = "https:///api/v1/" + // The rest of your launch method code } ``` From 768e8e149447d7779571ffc19a3760b3edb8ecd6 Mon Sep 17 00:00:00 2001 From: Gareth Reese Date: Thu, 10 Oct 2024 10:56:30 +0100 Subject: [PATCH 2/2] Updated max line length via prettier and suggested a small docs update --- docs/README.md | 14 ++++++++++++++ docs/docs/clients/client-side/ios.md | 6 ++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index ffd3eb1518af..b8761317da0a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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 --write +``` + ## Build ```console diff --git a/docs/docs/clients/client-side/ios.md b/docs/docs/clients/client-side/ios.md index 82d4af0a6ca8..40728d06fd01 100644 --- a/docs/docs/clients/client-side/ios.md +++ b/docs/docs/clients/client-side/ios.md @@ -288,7 +288,8 @@ Flagsmith.shared.cacheConfig.cache = ### 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: +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 @@ -308,7 +309,8 @@ func subscribeToFlagUpdates() { } ``` -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. +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