This repository was archived by the owner on Oct 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
This repository was archived by the owner on Oct 29, 2024. It is now read-only.
JSON Array variation is broken on iOS #112
Copy link
Copy link
Closed
Description
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
Because LD SDK on iOS uses as? (see here: https://github.com/launchdarkly/ios-client-sdk/blob/v5/LaunchDarkly/LaunchDarkly/LDClient.swift#L473) to cast, the type is extra important. I wanted to use an empty array as my default value but wouldn't work. This fixes my issue, but might need some reviewing as I'm not a expert on the native side.
Do you want a PR ?
Here is the diff that solved my problem:
diff --git a/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift b/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift
index 218e87d..7665ba0 100644
--- a/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift
+++ b/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift
@@ -144,8 +144,8 @@ class LaunchdarklyReactNativeClient: RCTEventEmitter {
resolve(LDClient.get(environment: environment)!.variation(forKey: flagKey, defaultValue: defaultValue) as String)
}
- @objc func jsonVariationArray(_ flagKey: String, defaultValue: Array<RCTConvert>, environment: String, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
- resolve(LDClient.get(environment: environment)!.variation(forKey: flagKey, defaultValue: defaultValue) as Array)
+ @objc func jsonVariationArray(_ flagKey: String, defaultValue: NSArray, environment: String, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {
+ resolve(LDClient.get(environment: environment)!.variation(forKey: flagKey, defaultValue: defaultValue as Array) as Array)
}
@objc func jsonVariationObject(_ flagKey: String, defaultValue: NSDictionary, environment: String, resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) -> Void {This issue body was partially generated by patch-package.
adrienharnay
Metadata
Metadata
Assignees
Labels
No labels