From 9d519efc746784a0e947a6190584d20f423c6c0b Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Tue, 17 Sep 2024 08:47:57 +0200 Subject: [PATCH] feat: swift and flutter sdk snippets (#8149) --- .../src/component/onboarding/sdkSnippets.ts | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/frontend/src/component/onboarding/sdkSnippets.ts b/frontend/src/component/onboarding/sdkSnippets.ts index 90984720f9..f573c76a8e 100644 --- a/frontend/src/component/onboarding/sdkSnippets.ts +++ b/frontend/src/component/onboarding/sdkSnippets.ts @@ -19,7 +19,7 @@ dotnet add package Newtonsoft.Json`, React: 'npm install @unleash/proxy-client-react unleash-proxy-client', Vue: 'npm install @unleash/proxy-client-vue', Svelte: 'npm install @unleash/proxy-client-svelte', - Swift: 'https://github.com/Unleash/unleash-proxy-client-swift', + Swift: 'https://github.com/Unleash/unleash-proxy-client-swift.git', Android: `implementation("io.getunleash:unleash-android:\${unleash.sdk.version}") // enabled required permissions @@ -164,7 +164,7 @@ app.mount('#app')`, `, - Swift: `import SwiftUI + Swift: `import Foundation import UnleashProxyClientSwift var unleash = UnleashProxyClientSwift.UnleashClient( @@ -185,11 +185,14 @@ unleash.start()`, .build() )`, Flutter: `import 'package:unleash_proxy_client_flutter/unleash_proxy_client_flutter.dart'; +import 'dart:async'; final unleash = UnleashClient( url: Uri.parse(''), clientKey: '', - appName: 'unleash-onboarding-flutter');`, + appName: 'unleash-onboarding-flutter'); + +unleash.start();`, }; // TODO: add idiomatic way of checking flag status that will populate metrics @@ -219,7 +222,14 @@ export const checkFlagCodeSnippets: Record = { React: ``, Vue: ``, Svelte: ``, - Swift: ``, + Swift: `Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in + print("Is enabled", unleashClient.isEnabled(name: "")) +} + +RunLoop.main.run()`, Android: ``, - Flutter: ``, + Flutter: `Timer.periodic(Duration(seconds: 1), (Timer timer) { + final flagStatus = unleash.isEnabled('counter'); + print('Flag is \${unleash.isEnabled("") ? "enabled" : "disabled"}'); +});`, };