mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
feat: swift and flutter sdk snippets (#8149)
This commit is contained in:
parent
b17c145769
commit
9d519efc74
@ -19,7 +19,7 @@ dotnet add package Newtonsoft.Json`,
|
|||||||
React: 'npm install @unleash/proxy-client-react unleash-proxy-client',
|
React: 'npm install @unleash/proxy-client-react unleash-proxy-client',
|
||||||
Vue: 'npm install @unleash/proxy-client-vue',
|
Vue: 'npm install @unleash/proxy-client-vue',
|
||||||
Svelte: 'npm install @unleash/proxy-client-svelte',
|
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}")
|
Android: `implementation("io.getunleash:unleash-android:\${unleash.sdk.version}")
|
||||||
|
|
||||||
// enabled required permissions
|
// enabled required permissions
|
||||||
@ -164,7 +164,7 @@ app.mount('#app')`,
|
|||||||
<FlagProvider {config}>
|
<FlagProvider {config}>
|
||||||
<App />
|
<App />
|
||||||
</FlagProvider>`,
|
</FlagProvider>`,
|
||||||
Swift: `import SwiftUI
|
Swift: `import Foundation
|
||||||
import UnleashProxyClientSwift
|
import UnleashProxyClientSwift
|
||||||
|
|
||||||
var unleash = UnleashProxyClientSwift.UnleashClient(
|
var unleash = UnleashProxyClientSwift.UnleashClient(
|
||||||
@ -185,11 +185,14 @@ unleash.start()`,
|
|||||||
.build()
|
.build()
|
||||||
)`,
|
)`,
|
||||||
Flutter: `import 'package:unleash_proxy_client_flutter/unleash_proxy_client_flutter.dart';
|
Flutter: `import 'package:unleash_proxy_client_flutter/unleash_proxy_client_flutter.dart';
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
final unleash = UnleashClient(
|
final unleash = UnleashClient(
|
||||||
url: Uri.parse('<YOUR_API_URL>'),
|
url: Uri.parse('<YOUR_API_URL>'),
|
||||||
clientKey: '<YOUR_API_TOKEN>',
|
clientKey: '<YOUR_API_TOKEN>',
|
||||||
appName: 'unleash-onboarding-flutter');`,
|
appName: 'unleash-onboarding-flutter');
|
||||||
|
|
||||||
|
unleash.start();`,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: add idiomatic way of checking flag status that will populate metrics
|
// TODO: add idiomatic way of checking flag status that will populate metrics
|
||||||
@ -219,7 +222,14 @@ export const checkFlagCodeSnippets: Record<SdkName, string> = {
|
|||||||
React: ``,
|
React: ``,
|
||||||
Vue: ``,
|
Vue: ``,
|
||||||
Svelte: ``,
|
Svelte: ``,
|
||||||
Swift: ``,
|
Swift: `Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in
|
||||||
|
print("Is enabled", unleashClient.isEnabled(name: "<YOUR_FLAG>"))
|
||||||
|
}
|
||||||
|
|
||||||
|
RunLoop.main.run()`,
|
||||||
Android: ``,
|
Android: ``,
|
||||||
Flutter: ``,
|
Flutter: `Timer.periodic(Duration(seconds: 1), (Timer timer) {
|
||||||
|
final flagStatus = unleash.isEnabled('counter');
|
||||||
|
print('Flag is \${unleash.isEnabled("<YOUR_FLAG>") ? "enabled" : "disabled"}');
|
||||||
|
});`,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user