Giter Site home page Giter Site logo

launchdarkly / react-native-client-sdk Goto Github PK

View Code? Open in Web Editor NEW
45.0 41.0 32.0 3.85 MB

LaunchDarkly Client-side SDK for React Native

License: Other

Ruby 2.32% Java 33.47% JavaScript 23.22% Objective-C 4.95% Swift 19.50% Shell 3.64% TypeScript 10.50% Kotlin 1.82% Objective-C++ 0.57%
launchdarkly sdk feature-flags feature-toggles launchdarkly-sdk react-native javascript typescript managed-by-terraform mirror

react-native-client-sdk's Introduction

LaunchDarkly Client-Side SDK for React Native

Important

As mentioned in the repository changelog, the launchdarkly-react-native-client-sdk project has been renamed to @launchdarkly/react-native-client-sdk. All future releases will be made from the new repository. Please consider upgrading and filing potential requests in that repository's issue tracker.

v9.x readme

NPM CircleCI Documentation

LaunchDarkly overview

LaunchDarkly is a feature management platform that serves trillions of feature flags daily to help teams build better software, faster. Get started using LaunchDarkly today!

Twitter Follow

Supported versions

React Native SDK version 10 is now released.

The LaunchDarkly React Native SDK version 10 is written in pure JavaScript and is compatible with Expo. It supports hot reloading. For customers using React Native 0.72.x - 0.73.x, use the latest 10.x release. If you cannot upgrade to the 10.x yet, use RN 8.0.x and 9.0.x respectively.

For React Native 0.71.x, use the latest 8.0.x release.

For React Native 0.69.x - 0.70.x support, use the latest 7.1.x release.

Getting started

Refer to the SDK documentation for instructions on getting started with using the SDK.

Learn more

Read our documentation for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the complete reference guide for this SDK.

Testing

We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs, as well as test networking behavior in a long-running application. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly.

Contributing

We encourage pull requests and other contributions from the community. Check out our contributing guidelines for instructions on how to contribute to this SDK.

About LaunchDarkly

  • LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
    • Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
    • Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
    • Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
    • Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
  • LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Read our documentation for a complete list.
  • Explore LaunchDarkly

Developing this SDK

  • Run yarn doctor in both the root and ManualTestApp directories and make sure everything is green
    • If watchman fails, you can try installing it manually brew reinstall watchman
  • Make sure you have modd installed so native code changes are hot reloaded
  • For ios run yarn dev-ios
  • For android run yarn dev-android

react-native-client-sdk's People

Contributors

adamivancza avatar andhappymoney avatar bolak avatar bwoskow-ld avatar c0state avatar christophby avatar dependabot[bot] avatar eeynard avatar eli-darkly avatar ember-stevens avatar gwhelanld avatar kparkinson-ld avatar launchdarklyci avatar launchdarklyreleasebot avatar ld-repository-standards[bot] avatar louis-launchdarkly avatar rodperottoni avatar sam1463 avatar shercoder avatar tanderson-ld avatar titozzz avatar torchhound avatar wilhelmeek avatar yusinto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-client-sdk's Issues

Listeners are called back with the name of the feature flag instead of the value

Describe the bug

on iOS, after registering a listener with registerFeatureFlagListener, toggling the feature flag on the console calls the listener with the flag name instead of the flag value.

To reproduce
create a feature flag in the launchdarkly, for this example test-flag ON:true OFF:false

client.allFlags().then(flags => {
        Object.keys(flags).forEach(flag => {
          client.registerFeatureFlagListener(flag, value => {
            console.log(flag, value);
          });
        });
      });

toggling test-flag from on to off will print

test-flag test-flag

Expected behavior

test-flag false

SDK version
RN version : 0.61.2
launchdarkly-react-native-client-sdk : 2.0.2

OS/platform
iOS 13.1.2

Thanks !

registerAllFlagsListener returns bizarre data in string response

Describe the bug
When the change listener for registerAllFlagsListener is called, it seems to pass a string value with a lot of additional data other than simply the names of changed feature flags. Here is an example of the response I get:

["enableMobileTestFlag": LaunchDarkly.LDChangedFlag(key: "enableMobileTestFlag", oldValue: Optional(1), oldValueSource: Optional(LaunchDarkly.LDFlagValueSource.server), newValue: Optional(0), newValueSource: Optional(LaunchDarkly.LDFlagValueSource.server))]

This whole value is a string response, and hard to parse on the JS side as it isn't even valid JSON. It seems like perhaps the native side representation of this data changed, and what is now getting passed back is essentially gibberish on the JS side.

To reproduce
Set up a change listener and log the response.

Expected behavior
I would expect the response to simply have the shape:

['enableMobileTestFlag']

Or, even more usefully, if the callback was passed the updated values rather than just the keys that have changed, that would be a lot more useful to us.

Logs
If applicable, add any log output related to your problem.

SDK version
3.2.1, the latest

Language version, developer tools
For instance, Go 1.11 or Ruby 2.5.3. If you are using a language that requires a separate compiler, such as C, please include the name and version of the compiler too.

OS/platform
For instance, Ubuntu 16.04, Windows 10, or Android 4.0.3. If your code is running in a browser, please also include the browser type and version.

Additional context
Add any other context about the problem here.

How does the JavaScript point to native code without linking libraries?

Describe the bug
I am unable to run my own application after installing the SDK due to a null native module. Additionally, attempting to link the library results in build failures.

To reproduce

  1. git clone https://github.com/launchdarkly/hello-react-native.git
  2. npm install
  3. pushd ios && pod install && popd
  4. react-native link launchdarkly-react-native-client-sdk
  5. react-native run ios

Expected behavior
I should be able to run the encapsulating application after installing the SDK with Cocoapods

Logs
Screen Shot 2019-05-09 at 1 19 29 PM

SDK version
1.0.1

Language version, developer tools, OS/platform

React Native Environment Info:
  System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 67.31 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 8.15.1 - ~/.nvm/versions/node/v8.15.1/bin/node
    Yarn: 1.15.2 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v8.15.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
  IDEs:
    Android Studio: 3.4 AI-183.5429.30.34.5452501
    Xcode: 10.1/10B61 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.3 => 16.8.3
    react-native: 0.59.5 => 0.59.5

Additional context
Since this library relies on native code, I am curious how the JavaScript code knows where to look for the native interface without linking the library. I can successfully run the Hello application as is after an npm install and a pod install. However when I try to install the React Native SDK in my own application and run, I receive the Native module cannot be null error.

After linking the React Native SDK to try and mitigate this issue, in both my own project and the Hello project, I see the following errors:

❌  /Users/alex.young/q/mobile-dashboard/node_modules/launchdarkly-react-native-client-sdk/ios/../../../ios/Pods/boost-for-react-native/boost/compatibility/cpp_c_headers/cstdarg:10:1: unknown type name 'namespace'

namespace std {
         ^

❌  /Users/alex.young/q/mobile-dashboard/node_modules/launchdarkly-react-native-client-sdk/ios/../../../ios/Pods/boost-for-react-native/boost/tr1/tr1/utility:21:20: 'utility' file not found
#     include_next <utility>
                ^

❌  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:10: could not build module 'Darwin'
#include <sys/types.h>
        ^

❌  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:10: could not build module 'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
        ^

❌  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/usr/include/objc/objc.h:31:10: could not build module 'Darwin'
#include <sys/types.h>      // for __DARWIN_NULL
         ^

❌  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/CoreServices.framework/Headers/UTCoreTypes.h:19:10: could not build module 'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
         ^

❌  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:9: could not build module 'Foundation'
#import <Foundation/Foundation.h>
        ^

error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening MBQ.xcworkspace

Here is my Podfile:

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '9.0'

target 'MBQ' do
  use_frameworks!

  REACT_NATIVE = '../node_modules/react-native'

  pod 'yoga', path: "#{REACT_NATIVE}/ReactCommon/yoga/yoga.podspec"
  pod 'React', path: REACT_NATIVE, subspecs: [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
  ]

  # React Native third party dependencies
  pod 'DoubleConversion', :podspec => "#{REACT_NATIVE}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{REACT_NATIVE}/third-party-podspecs/glog.podspec"
  pod 'Folly', :podspec => "#{REACT_NATIVE}/third-party-podspecs/Folly.podspec"

  pod 'LaunchDarkly', :git => 'https://github.com/launchdarkly/ios-client-sdk.git', :tag => '3.0.0-beta.3'
  pod 'LaunchdarklyReactNativeClient', path: '../node_modules/launchdarkly-react-native-client-sdk/ios/'

  target 'MBQTests' do
    inherit! :search_paths
  end

end

Cannot build with iOS client SDK 3.0.1

Describe the bug
Attempting to build the hello-react-native app with iOS SDK 3.0.1 fails even though the React Native SDK Podspec allows it

To reproduce

  1. git clone https://github.com/launchdarkly/react-native-client-sdk.git
  2. pushd react-native-client-sdk && npm link && popd
  3. git clone https://github.com/launchdarkly/hello-react-native.git
  4. pushd hello-react-native && npm link launchdarkly-react-native-client-sdk
  5. npm install
  6. pushd ios && sed -i '' 's/3.0.0-beta.3/3.0.1/g' Podfile
  7. pod install
  8. Link glog and DoubleConversion frameworks to React Pod target
  9. react-native link
  10. react-native run-ios

Expected behavior
Building the hello-react-native app with iOS SDK 3.0.x should succeed

Logs

▸ Building Pods/LaunchdarklyReactNativeClient [Debug]
▸ Check Dependencies
▸ Compiling LaunchdarklyReactNativeClient.swift

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:7:39: use of undeclared type 'LDObserverOwner'
    private var listenerKeys: [String:LDObserverOwner] = [:]
                                      ^~~~~~~~~~~~~~~

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:47:78: cannot assign value of type 'URL' to type 'String?'
            ldConfig.baseUrl = URL.init(string: config["baseUri"] as! String)!
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:59:13: value of type 'LDConfig' has no member 'eventCapacity'
            ldConfig.eventCapacity = config["eventsCapacity"] as! Int
            ^~~~~~~~ ~~~~~~~~~~~~~

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:63:13: value of type 'LDConfig' has no member 'eventFlushInterval'
            ldConfig.eventFlushInterval = TimeInterval(config["eventsFlushIntervalMillis"] as! Float / 1000)
            ^~~~~~~~ ~~~~~~~~~~~~~~~~~~

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:67:42: cannot assign value of type 'TimeInterval' (aka 'Double') to type 'NSNumber?'
            ldConfig.connectionTimeout = TimeInterval(config["connectionTimeoutMillis"] as! Float / 1000)
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:71:13: value of type 'LDConfig' has no member 'flagPollingInterval'; did you mean 'pollingInterval'?

            ldConfig.flagPollingInterval = TimeInterval(config["pollingIntervalMillis"] as! Float / 1000)
            ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:75:13: value of type 'LDConfig' has no member 'backgroundFlagPollingInterval'
            ldConfig.backgroundFlagPollingInterval = TimeInterval(config["backgroundPollingIntervalMillis"] as! Float / 1000)
                        ^

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:83:66: use of unresolved identifier 'LDStreamingMode'
            ldConfig.streamingMode = (config["stream"] != nil) ? LDStreamingMode.streaming : LDStreamingMode.polling
            ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:87:13: value of type 'LDConfig' has no member 'enableBackgroundUpdates'
            ldConfig.enableBackgroundUpdates = !(config["disableBackgroundUpdating"] as! Bool)
                                                                                             ^~~~~~~~~~~~~~~

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:91:13: value of type 'LDConfig' has no member 'startOnline'
            ldConfig.startOnline = !(config["offline"] as! Bool)
            ^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:95:13: value of type 'LDConfig' has no member 'isDebugMode'
            ldConfig.isDebugMode = config["debugMode"] as! Bool
            ^~~~~~~~ ~~~~~~~~~~~

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:102:20: use of unresolved identifier 'LDUser'
        var user = LDUser()
            ^~~~~~~~ ~~~~~~~~~~~

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:168:40: type 'LDClient' has no member 'shared'
        let stringFlagValue: String? = LDClient.shared.variation(forKey: flagKey)
                                      ^~~~~~~~ ~~~~~~

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:283:42: use of undeclared type 'LDObserverOwner'
        let flagChangeOwner = flagKey as LDObserverOwner
                                         ^~~~~~~~~~~~~~~

❌  /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift:293:17: type 'LDClient' has no member 'shared'
        resolve(LDClient.shared.config.enableBackgroundUpdates)
                                         ^~~~~~~~~~~~~~~

** BUILD FAILED **
The following build commands failed:
	CompileSwift normal x86_64 /Users/alex.young/q/hello-react-native/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient.swift
	CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(2 failures)

SDK version
1.0.1

Language version, developer tools
OS/platform

React Native Environment Info:
  System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 182.06 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 8.15.1 - ~/.nvm/versions/node/v8.15.1/bin/node
    Yarn: 1.15.2 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v8.15.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
  IDEs:
    Android Studio: 3.4 AI-183.5429.30.34.5452501
    Xcode: 10.1/10B61 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.6.3 => 16.6.3
    react-native: 0.57.7 => 0.57.7
  npmGlobalPackages:
    launchdarkly-react-native-client-sdk: 1.0.1
    react-native-cli: 2.0.1

Additional context
I noticed similar logs being discussed in #1. I also see the same behavior when using iOS SDK 3.0.0. I can successfully build 3.0.0-beta.3. One would expect forwards compatibility with newer libraries. One odd thing I noticed is that 3.0.0-beta.3 seems to be completely divergent from master, where the expectation of semantic versioning is that 3.0.0.beta.3 is behind 3.0.0 and 3.0.1

Error on build related to swift compiler version

Describe the bug
Following error occurs on build:

Module compiled with Swift 5.3 cannot be imported by the Swift 5.3.1 compiler: /Users/xyz/Library/Developer/Xcode/DerivedData/conqasiteapp-abffynglrkfpmcfouodvfxjmzynn/Build/Products/Debug-iphonesimulator/LaunchDarkly/LaunchDarkly.swiftmodule/x86_64-apple-ios-simulator.swiftmodule

To reproduce

Expected behavior
Successfully built and launched on iOS simulator

Logs
If applicable, add any log output related to your problem.

SDK version
3.2.2

Language version, developer tools

  • xcode: version 12.2 (12B45b)
  • react native: 0.61.0

OS/platform
iPhone 11 simulator

A option to not use `use_frameworks!`

Is this a support request?
No

Describe the bug
use_frameworks! is often incompatible with other pods and even the react native repo admits so: https://github.com/react-native-community/releases/blob/master/CHANGELOG.md

In my case, its not compatible with react-native-firebase, most likely some others.

I've tried to not use it and instead add :modular_headers => true to React and DarklyEventSource but get this instead:

▸ Check Dependencies
    no rule to process file '/Users/huanvu/Documents/hotlap-react/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient-Bridging-Header.h' of type sourcecode.c.h for architecture x86_64
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening hotlap.xcworkspace

Not sure what to do here but if you have any instructions to use this sdk without use_frameworks! it would be of great help. Thank you!

To reproduce
Add :modular_headers => true to React and DarklyEventSource in Podfile.
Build.

Expected behavior
Project builds ok.

Logs

▸ Check Dependencies
    no rule to process file '/Users/huanvu/Documents/hotlap-react/node_modules/launchdarkly-react-native-client-sdk/ios/LaunchdarklyReactNativeClient-Bridging-Header.h' of type sourcecode.c.h for architecture x86_64
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening hotlap.xcworkspace

SDK version
2.0.0

Language version, developer tools
React 16.8.6, React Native 0.59.9, XCode 10.2.1, Swift 4.2

OS/platform
OSX

Additional context
none

Android: Error: Cannot convert argument of type class com.launchdarkly.android.ConnectionInformationState

Describe the bug
Calling .getConnectionInformation() method is throwing error on Android.

To reproduce

/* eslint-disable react-native/no-inline-styles */
import React, {useEffect, useState} from 'react';
import {SafeAreaView, View, Text} from 'react-native';
import LDClient from 'launchdarkly-react-native-client-sdk';

const client = new LDClient();
const clientConfig = {
  mobileKey: 'MOBILE_KEY',
  stream: true,
  offline: false,
};

const userConfig = {key: 'user123'};

const App = () => {
  const [allFlags, setAllFlags] = useState(false);
  const [connInfo, setConnInfo] = useState(false);
  const [backgroundColor, setBackgroundColor] = useState('white');
  const [err, setError] = useState(null);

  useEffect(() => {
    (async () => {
      try {
        await client.configure(clientConfig, userConfig);

        const bgColor = await client.stringVariation(
          'backgroundColor',
          'yellow',
        );
        setBackgroundColor(bgColor);

        const flags = await client.allFlags();
        setAllFlags(flags);

        const info = await client.getConnectionInformation();
        setConnInfo(info);
      } catch (error) {
        console.log(error);
        setError(error.message);
      }
    })();

    return () => {
      client.close();
    };
  }, []);

  return (
    <View style={{flex: 1}}>
      <View style={{flex: 1}}>
        <SafeAreaView style={{flex: 1, backgroundColor: 'tomato'}}>
          <Text style={{fontSize: 20}}>{connInfo}</Text>
          <Text style={{fontSize: 20}}>{err}</Text>
        </SafeAreaView>

        <SafeAreaView style={{flex: 1, backgroundColor}}>
          <Text
            style={{
              fontSize: 20,
              backgroundColor: 'rgba(255,255,255,0.3)',
            }}>
            {JSON.stringify(allFlags, null, 2)}
          </Text>
        </SafeAreaView>
      </View>
    </View>
  );
};

export default App;

Expected behavior
Calling .getConnectionInformation() method should return meaningful error.

Logs

Error: Cannot convert argument of type class com.launchdarkly.android.ConnectionInformationState
    at Object.promiseMethodWrapper [as getConnectionInformation] (NativeModules.js:103)
    at LDClient.getConnectionInformation (index.js:257)
    at _callee$ (App.js:35)
    at tryCatch (runtime.js:63)
    at Generator.invoke [as _invoke] (runtime.js:293)
    at Generator.next (runtime.js:118)
    at tryCatch (runtime.js:63)
    at invoke (runtime.js:154)
    at runtime.js:164
    at tryCallOne (core.js:37)

SDK version

    "launchdarkly-react-native-client-sdk": "^3.2.1"

Language version, developer tools

System:
    OS: macOS 10.15.7
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 4.16 GB / 32.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.18.3 - ~/.nvm/versions/node/v12.18.3/bin/node
    Yarn: 1.21.1 - /usr/local/bin/yarn
    npm: 6.14.6 - ~/.nvm/versions/node/v12.18.3/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 3.6 AI-192.7142.36.36.6200805
    Xcode: 12.0.1/12A7300 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_232 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1
    react-native: 0.63.3 => 0.63.3
    react-native-macos: Not Found

Additional context
Running it on a physical device Pixel 3a with Android 10.

Support for Xcode 11

Is your feature request related to a problem? Please describe.
Given the words from Apple Store: Starting April, 2020, all apps submitted to the App Store will need to be built with Xcode 11. Xcode 11 requires macOS Mojave 10.14.3 or later.

Describe the solution you'd like
Do you plan to release a SDK before the deadline ( April, 2020).

allFlags returns json strings instead of js objects

Describe the bug
I am using the android emulator to run a react-native application.
When I request a json variation by calling client.allFlags I get back a json string. iOS correctly returns a js object.
If I request the variation directly (client.jsonVariation("my-flag")) I get a js object.

To reproduce
Steps to reproduce the behavior.

  1. Create a json variation.
  2. Run the react-native application on android emulator (Pixel 2 API 29).
  3. Request all flags.

Expected behavior
I would expect the allFlags response in android to contain my variation as a js object. E.g:

{
  "my-key" : {"hello":"world"}
}

Instead it returns the json variation as a string.

{
  "my-key" : "{\"hello\":\"world\"}"
}

SDK version
2.0.0

OS/platform
Android SDK 28

LDClient.getForMobileKey() was called before init()

Describe the bug
After updating to latest version of react native (0.64.1) with Hermes enabled and using latest version of launchdarkly-react-native-client-sdk (4.2.0), I get the following error when trying to configure the client: Error: LDClient.getForMobileKey() was called before init()!. It then obviously fails to fetch the flags.

Note: This is only happening on Android

To reproduce

  1. Start a new project using react-native: 0.64.1
  2. Turn on Hermes for both Android
  3. Install latest version of launchdarkly-react-native-client-sdk: 4.2.0
  4. Try to configure the client

Expected behavior
Client should be configured properly and should be able to fetch flags

Logs

Error: LDClient.getForMobileKey() was called before init()!
Error: LDClient.getForMobileKey() was called before init()!
    at promiseMethodWrapper (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:3404:45)
    at isInitialized (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:183558:59)
    at configure (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:183354:31)
    at configureLaunchDarkly$ (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:183256:65)
    at call (native)
    at tryCatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:1450:23)
    at invoke (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:1623:32)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:1493:30)
    at call (native)
    at tryCatch (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:1450:23)
    at invoke (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:1523:30)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:1553:19)
    at tryCallTwo (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:28622:9)
    at doResolve (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:28786:25)
    at Promise (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:28645:14)
    at callInvokeWithMethodAndArg (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:1552:33)
    at enqueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:1557:157)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:1493:30)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:1574:69)
    at configureLaunchDarkly (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:183235:40)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:183286:30)
    at invokePassiveEffectCreate (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:23151:32)
    at apply (native)
    at invokeGuardedCallbackProd (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:9677:21)
    at apply (native)
    at invokeGuardedCallback (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:9781:42)
    at flushPassiveEffectsImpl (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:23221:36)
    at unstable_runWithPriority (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:51896:30)
    at runWithPriority (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:13504:41)
    at flushPassiveEffects (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:23110:35)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:23006:36)
    at workLoop (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:51847:48)
    at flushWork (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:51822:28)
    at _flushCallback (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:51532:24)
    at apply (native)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:29214:26)
    at _callTimer (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:29130:17)
    at callTimers (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:29339:19)
    at apply (native)
    at __callFunction (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:3894:36)
    at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:3618:31)
    at __guard (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:3845:15)
    at callFunctionReturnFlushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.airbase&modulesOnly=false&runModule=true:3617:21)

SDK version
"launchdarkly-react-native-client-sdk": "^4.2.0",

OS/platform
Android

package name com.reactlibrary is used by other libraries and so might cause issues for projects with lots of dependencies

Describe the bug
When I add the SDK to my project my android build fails due to the error below. I believe that this is caused by the android package name being com.reactlibrary. This name is default and so is also used by other libraries and so if you ever happen to have more than one in your project it will fail. Would it be possible to change the package name to something less risky? I tried changing locally under my node modules and it then built fine.

> Task :app:transformClassesWithMultidexlistForProductionRelease FAILED
D8: Program type already present: com.reactlibrary.BuildConfig

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForProductionRelease'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list:
  Error while merging dex archives:
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: com.reactlibrary.BuildConfig

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1m 58s
418 actionable tasks: 20 executed, 398 up-to-date

To reproduce
It is difficult to know exactly which other dependency in my project is clashing with this SDK so not sure how to reproduce but I feel like it might be good if we can change the name here to be safe.

SDK version
2.0.2

[Android] Client was already initialized error

Describe the bug
I believe there's an issue when the App Context is alive but Activity Context has been destroyed (difference on Android explained here). As the JS side is trying to initialize/configure the LD client along with the UI, this seems to cause a conflict. My guess is that the client is still around within the Application Context?
The font change in the reproduction steps below is intended as a short-cut to destroy the UI/Activity Context.

This is somewhat related to #10, but here an actual issue rather than a 'nice to have' I think.

To reproduce

  1. Download & set up the hello world project as described: https://github.com/launchdarkly/hello-react-native
  2. Run on Android (I've been using emulator)
  3. With the app running on the device/emulator, navigate to device Settings > Display > Font size
  4. Change the font size
  5. Return to the hello world app

Expected behavior
The app to be able to re-create the activity context.

SDK version
2.2.0

Language version, developer tools
React Native 0.61.2

OS/platform
Android 9

Screenshot
Screenshot_1581987723

registerAllFlagsListener passes a JSON string to its handler, not an array of flags

Is this a support request?
no

Describe the bug
An "all flags" listener is being passed a string representation of a JSON array, not the array itself (which is what the TS types specify it receives).

const handler = (allFlags) => {
  console.log({ allFlags })
}
client.registerAllFlagsListener(handlerId, handler);
// assuming a flag called `'feature-flag'`, what's logged is:
// {"allFlags": "[\"feature-flag\"]"}

To reproduce
see above

Expected behavior
Argument values match their TS types

Logs
n/a

SDK version
4.0.3

Language version, developer tools
React native, I'm not sure what JS version the device is running

OS/platform
Android 11 simulator, Pixel 2 emulator

Additional context
Add any other context about the problem here.

Unable to build on iOS

Hi all,
Congrats on the 1.0.0 release! Really appreciate the hard work.

Describe the bug
When running pod install I get this error:

[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `LaunchDarkly` depends upon `DarklyEventSource`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

The Swift pod `LaunchdarklyReactNativeClient` depends upon `React`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

When building in Xcode I get these errors:

warning: no rule to process file '/Users/jwilliamson/Developer/QBMobile/node_modules/launchdarkly-react-native-client/ios/LaunchdarklyReactNativeClient-Bridging-Header.h' of type sourcecode.c.h for architecture x86_64
The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. Supported values are: 4.0, 4.2, 5.0. This setting can be set in the build settings editor.

To reproduce
Follow the installation instructions here and the readme here

Expected behavior
Should be able to build successfully using Xcode or react-native run-ios

Logs
See above

SDK version
1.0.0

Language version, developer tools
React Native

OS/platform
iOS

Swift Compiler Error in Xcode 11.4

Describe the bug
Our project is failing to compile under Xcode 11.4, due to a Swift compile error within the auto-linked LaunchDarkly SDK.

image

To reproduce
Attempt to compile a vanilla React Native project with the auto-linked LaunchDarkly SDK with Xcode 11.4.

Expected behavior
Successful compilation.

Logs

Protocol 'Collection' can only be used as a generic constraint because it has Self or associated type requirements

SDK version

JavaScript
[email protected]:
  version "2.17.0"
  resolved "https://registry.yarnpkg.com/launchdarkly-js-client-sdk/-/launchdarkly-js-client-sdk-2.17.0.tgz#7be9f1b12f7a0ea90ba9dfed73d076e97b78656a"
  integrity sha512-KLKFtud5k9tH2BsaCf7dNyfqaHM4MITLQbriDpqi5zYDAhNYh6qZRIuriCTOohhw0/0GoA+oMHDhI4zDQ7nVww==
  dependencies:
    escape-string-regexp "^1.0.5"
    launchdarkly-js-sdk-common "3.2.2"
[email protected]:
  version "3.2.2"
  resolved "https://registry.yarnpkg.com/launchdarkly-js-sdk-common/-/launchdarkly-js-sdk-common-3.2.2.tgz#26f8a8bcf8e3391e3bf6fdf72e5883d3cc8a9c7d"
  integrity sha512-WBIMk3c1s3JGpSvDRZpDr0D4dDPsFkscDmcOoaoXnkW6PdacfUz9KKJ9bKTM+akNWE2DsZ3ttEz4rATEFeOnVA==
  dependencies:
    base64-js "^1.3.0"
    fast-deep-equal "^2.0.1"
    uuid "^3.3.2"
launchdarkly-react-client-sdk@^2.18.0:
  version "2.18.0"
  resolved "https://registry.yarnpkg.com/launchdarkly-react-client-sdk/-/launchdarkly-react-client-sdk-2.18.0.tgz#7563878ae9768ba227f2bdd6779f88dde1f7eebd"
  integrity sha512-g4jyNbDSL4qptnV9Hmca8b1Z/bXiF1GXVuEa6pISNSo4pdnPgKYjUshjiRIBq1hoi3+oO4PPQhS5DxdVSf6lVA==
  dependencies:
    launchdarkly-js-client-sdk "2.17.0"
    lodash.camelcase "^4.3.0"
    uuid "^3.3.2"
launchdarkly-react-native-client-sdk@^3.0.0:
  version "3.0.0"
  resolved "https://registry.yarnpkg.com/launchdarkly-react-native-client-sdk/-/launchdarkly-react-native-client-sdk-3.0.0.tgz#24a5a30544f215fd188a69a92183150387419db7"
  integrity sha512-gmeQpTwFoH6E3PNJL4nZv2fdIORoPRFnxt5+Ql6TLShvMcFNBxGaA/ZlGLOXW79zxaXd51Fw4F5xtIDXw8jQtA==
CocoaPods
  - LaunchDarkly (4.4.1):
    - LaunchDarkly/Core (= 4.4.1)
  - LaunchDarkly/Core (4.4.1):
    - DarklyEventSource (~> 4.1.0)
  - LaunchdarklyReactNativeClient (3.0.0):
    - LaunchDarkly (= 4.4.1)

Language version, developer tools
Xcode 11.4 (11E146)

OS/platform
macOS 10.15.4

Methods called on Client after calling .close() throw errors on iOS

Is this a support request?
This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the SDK code. If you're not sure whether the problem you are having is specifically related to the SDK, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going here or by emailing [email protected].

Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.

Describe the bug
Given an instantiated client LDClient, calling .close() will cause any future method calls on that client to throw an error in from the swift code.

To reproduce
Configure a client. Call .close() then try calling a flag check.

Expected behavior
The subsequent flag check should resolve to the given default value.

Logs

LaunchdarklyReactNativeClient.swift:239:31
Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value

(seen this same error on other calls from that class as well)

SDK version
This error was seen on both 4.0.2 and 4.1.1

Language version, developer tools
React Native/Xcode

OS/platform
Error only occurs on iOS, version seems to not matter.

Configuring the client doesn't return if user is offline

Describe the bug
The .configure() call on the client never returns or throws if the user is offline.

To reproduce
This can be reproduced in the hello-react-native app.

  1. Add some logging before/after the await client.configure(config, user); call
  2. Go offline (eg. for easy replication in iOS simulator, turn computer's Wifi/ethernet off)
  3. Launch the app
  4. The logging before configure shows, but not the logging after nor in the catch

Expected behavior
Expect configure to either return or throw an error.

SDK version
Tested on 4.2.1 (our app) and 4.2.0 (hello-react-native)

Language version, developer tools
Node 4.15.0, TypeScript 4.2.4

OS/platform
iOS 12.4

Building app using v4.0.0 fails with LDSwiftEventSource/LDSwiftEventSource.modulemap not found

Describe the bug

After upgrading to v4.0.0, I get an error whenever I try to build the app using Release mode.

Then I ran the following commands:

$ cd ios
$ pod cache clean --all
$ pod install

Following this, I started to install the app using Release mode.

$ react-native run-ios --scheme=vibrant-testnet --configuration=Release --simulator 'iPhone SE (2nd generation)'

To reproduce

Build fails with several outputs like fatal error: module map file '/Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Products/Release-iphonesimulator/LDSwiftEventSource/LDSwiftEventSource.modulemap' not found.

Expected behavior

Builds successfully without errors.

Logs

fatal error: module map file '/Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Products/Release-iphonesimulator/LDSwiftEventSource/LDSwiftEventSource.modulemap' not found
fatal error: module map file '/Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Products/Release-iphonesimulator/LDSwiftEventSource/LDSwiftEventSource.modulemap' not found
fatal error: module map file '/Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Products/Release-iphonesimulator/LDSwiftEventSource/LDSwiftEventSource.modulemap' not found
fatal error: module map file '/Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Products/Release-iphonesimulator/LDSwiftEventSource/LDSwiftEventSource.modulemap' not found
fatal error: module map file '/Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Products/Release-iphonesimulator/LDSwiftEventSource/LDSwiftEventSource.modulemap' not found
1 error generated.
fatal error: module map file '/Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Products/Release-iphonesimulator/LDSwiftEventSource/LDSwiftEventSource.modulemap' not found
1 error generated.
fatal error: module map file '/Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Products/Release-iphonesimulator/LDSwiftEventSource/LDSwiftEventSource.modulemap' not found
fatal error: module map file '/Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Products/Release-iphonesimulator/LDSwiftEventSource/LDSwiftEventSource.modulemap' not found
1 error generated.
fatal error: module map file '/Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Products/Release-iphonesimulator/LDSwiftEventSource/LDSwiftEventSource.modulemap' not found
1 error generated.
3 errors generated.
6 errors generated.
fatal error: module map file '/Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Products/Release-iphonesimulator/LDSwiftEventSource/LDSwiftEventSource.modulemap' not found
1 error generated.

….

fatal error: module map file '/Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Products/Release-iphonesimulator/LDSwiftEventSource/LDSwiftEventSource.modulemap' not found
1 error generated.


** BUILD FAILED **


The following build commands failed:
	CompileC /Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Intermediates.noindex/vibrant.build/Release-iphonesimulator/vibrant-testnet.build/Objects-normal/x86_64/Vibrant\ Testnet_vers.o /Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Intermediates.noindex/vibrant.build/Release-iphonesimulator/vibrant-testnet.build/DerivedSources/Vibrant\ Testnet_vers.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler
	CompileC /Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Intermediates.noindex/vibrant.build/Release-iphonesimulator/vibrant-testnet.build/Objects-normal/i386/Vibrant\ Testnet_vers.o /Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Intermediates.noindex/vibrant.build/Release-iphonesimulator/vibrant-testnet.build/DerivedSources/Vibrant\ Testnet_vers.c normal i386 c com.apple.compilers.llvm.clang.1_0.compiler
	CompileC /Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Intermediates.noindex/vibrant.build/Release-iphonesimulator/vibrant-testnet.build/Objects-normal/arm64/Vibrant\ Testnet_vers.o /Users/fnando/Library/Developer/Xcode/DerivedData/vibrant-bunfharcsfqcsyhkzymjoyghvrxm/Build/Intermediates.noindex/vibrant.build/Release-iphonesimulator/vibrant-testnet.build/DerivedSources/Vibrant\ Testnet_vers.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler
(3 failures)

SDK version

v4.0.0

Language version, developer tools

  • react-native 0.63.3
  • Xcode 12.4 (12D4e)
  • node v12.19.0

OS/platform

  • macOS 11.12.3 (Mac Mini M1 running with terminal running in x86_64 mode)
  • Simulator Version 12.4 (940.20), SimulatorKit 597.13.0.1, CoreSimulator 732.18.6

Xcode 12 Support

Is this a support request?
Given the words from Apple Store: Starting April 2021, all iOS and iPadOS apps submitted to the App Store must be built with Xcode 12 and the iOS 14 SDK.

Describe the solution you'd like
Do you plan to release an SDK before the April 2021 deadline?

"AAPT: error: resource android:attr/dialogCornerRadius not found" when building Android assets

I'm getting the below error with the latest launch darkly react native SDK

To reproduce
From root of react native app, run cd android && ./gradlew assembleRelease

Expected behavior
I expect the android assets to build successfully

Logs

Execution failed for task ':launchdarkly-react-native-client-sdk:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > 1 exception was raised by workers:
     com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
     /Users/sliu/.gradle/caches/transforms-2/files-2.1/b223af57039658e6101987f96510dfd5/appcompat-1.0.2/res/values-v28/values-v28.xml:5:5-8:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
         
     /Users/sliu/.gradle/caches/transforms-2/files-2.1/b223af57039658e6101987f96510dfd5/appcompat-1.0.2/res/values-v28/values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
         
     /Users/sliu/.gradle/caches/transforms-2/files-2.1/d67585c7f2ea0d699d201615e94006d0/core-1.0.1/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
         
     /Users/sliu/.gradle/caches/transforms-2/files-2.1/d67585c7f2ea0d699d201615e94006d0/core-1.0.1/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.

SDK version
"3.1.0"

Language version, developer tools

OS/platform
macOS Catalina 10.15.4

Additional context
Not super familiar with gradle/Android build system but there seems to be an inconsistency in the versions being specified here. Your build.gradle references compile SDK 27 in one place and then 28 in another:

buildscript {
    ext {
        buildToolsVersion = "28.0.2"
        minSdkVersion = 16
        compileSdkVersion = 28 // <---------- different version below
        targetSdkVersion = 27 // <---------- also why is target "27" here, shouldn't it also be 28?
        supportLibVersion = "28.0.0"
    }
    repositories {
        jcenter()
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
    }
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion 27 // <---------- different version above

If I change locally all compile and target SDK versions to 28, it fixes the error in my case.

Also, https://stackoverflow.com/a/50496385/522415 seems related...
Also, anecdotally, most react libraries I've inspected reference Android SDK version 28

Fetch flag state synchronously

Is your feature request related to a problem? Please describe.
I was wondering if there was a way to fetch the flag state synchronously (based on cached values). I've gone through the documentation and example application and each evaluation seems to return a promise.

We use feature flags to flag navigation so It's important to us for flag evaluations to be instant.

Describe the solution you'd like
Synchronous way of fetching flag state (boolean)

Describe alternatives you've considered
Hand rolling a caching system with redux and redux-persist that gets written on launch with allFlags() and gets overwritten each time a flag changes.

Additional context
React native

Function to register listener for all flags

Is your feature request related to a problem? Please describe.
I would love to have a function that can listen and respond in real time to changes to any flag, instead of having to create individual listeners for specific flags with registerFeatureFlagListener.

Describe the solution you'd like
A function (registerAllFlagsListener, like what is mentioned here) that takes a callback to be called upon receiving a change to any and all of my feature flags.

Describe alternatives you've considered
Creating individual listeners with registerFeatureFlagListener for each flag key in an array. Would like to be able to rig my app up to respond to all flags without having to do that tedious work.

Thank you for all your hard work!

Exception 'configureWithTimeout:userConfig:timeout:resolve:reject: is not a recognized Objective-C method.'

Describe the bug
configure throws exception when timeout is specified.

To reproduce
The bug is reproduced by applying the following patch to launchdarkly/hello-react-native.

diff --git a/App.js b/App.js
index 24102300..7514fdf0 100644
--- a/App.js
+++ b/App.js
@@ -52,7 +52,7 @@ export default class App extends React.Component {

       let user = {key: this.state.userKey};

-      await client.configure(config, user);
+      await client.configure(config, user, 3);
       // eslint-disable-next-line react/no-did-mount-set-state
       this.setState({ldClient: client});
     } catch (err) {

The full source code can be found here.

Expected behavior
No exceptions are thrown.

Logs
I filtered mobileKey.

Exception 'configureWithTimeout:userConfig:timeout:resolve:reject: is not a recognized Objective-C method.' was thrown while invoking configureWithTimeout on target LaunchdarklyReactNativeClient with params (
        {
        backgroundPollingIntervalMillis = 3600000;
        connectionTimeoutMillis = 10000;
        debugMode = 1;
        disableBackgroundUpdating = 0;
        eventsCapacity = 100;
        eventsFlushIntervalMillis = 30000;
        mobileKey = "[Filtered]";
        offline = 0;
        pollUri = "https://app.launchdarkly.com";
        pollingIntervalMillis = 300000;
        stream = 1;
        streamUri = "https://clientstream.launchdarkly.com";
        useReport = 0;
        wrapperName = "react-native-client-sdk";
        wrapperVersion = "4.2.0";
    },
        {
        anonymous = 0;
        key = "user key";
    },
    3,
    8356,
    8357
)
callstack: (
	0   CoreFoundation                      0x00007fff20422fba __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007fff20193ff5 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff20422de3 +[NSException raise:format:] + 0
	3   Foundation                          0x00007fff207749b0 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
	4   HelloReactNative                    0x00000001005c3b3f -[RCTModuleMethod processMethodSignature] + 1023
	5   HelloReactNative                    0x00000001005cb96e -[RCTModuleMethod invokeWithBridge:module:arguments:] + 190
	6   HelloReactNative                    0x00000001005d0ab7 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 1495
	7   HelloReactNative                    0x00000001005d02d5 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 165
	8   HelloReactNative                    0x00000001005d021c ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28
	9   libdispatch.dylib                   0x00007fff2010670d _dispatch_call_block_and_release + 12
	10  libdispatch.dylib                   0x00007fff201078df _dispatch_client_callout + 8
	11  libdispatch.dylib                   0x00007fff2010de15 _dispatch_lane_serial_drain + 715
	12  libdispatch.dylib                   0x00007fff2010e98c _dispatch_lane_invoke + 400
	13  libdispatch.dylib                   0x00007fff20118f81 _dispatch_workloop_worker_thread + 772
	14  libsystem_pthread.dylib             0x00007fff6033f499 _pthread_wqthread + 314
	15  libsystem_pthread.dylib             0x00007fff6033e467 start_wqthread + 15
)

RCTFatal
facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&, int, (anonymous namespace)::SchedulingContext)
facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const
invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_lane_serial_drain
_dispatch_lane_invoke
_dispatch_workloop_worker_thread
_pthread_wqthread
start_wqthread

SDK version

    "launchdarkly-react-native-client-sdk": "^4.2.0",

Language version, developer tools

$ node node_modules/react-native/local-cli/cli.js info
info Fetching system and libraries information...
System:
    OS: macOS 11.2.3
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 82.30 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.4.0 - ~/.anyenv/envs/nodenv/versions/14.4.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.5 - ~/.anyenv/envs/nodenv/versions/14.4.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /Users/yskoht/.anyenv/envs/rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 28, 29, 30
      Build Tools: 28.0.3, 29.0.2, 30.0.2
      System Images: android-23 | Intel x86 Atom_64, android-24 | Google Play Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-26 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6626763
    Xcode: 12.5/12E262 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_265 - /Users/yskoht/.anyenv/envs/jenv/shims/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1
    react-native: 0.64.0 => 0.64.0
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

OS/platform
macOS 11.2.3

Enable initializing multiple clients

Is your feature request related to a problem? Please describe.
Yes. I'm working on an app that allows the user to toggle between multiple environments (staging, production, etc.). Each environment corresponds to a different database and a different LaunchDarkly environment with different targeting rules.

The problem I'm having is that the user gets "stuck" with the feature flag values for the first environment they select. For example, if the user chooses "production", the app initializes a LaunchDarkly client with the mobileKey for production. That way, the client provides the appropriate feature flag values for the production environment. However, if the user then toggles to the "staging" environment, the client still provides the feature flag values for production.

I attempted to create a different client for each environment, but when I tried to initialize a second client, I got an error: "Client was already initialized".

Describe the solution you'd like
I'd like to be able to create multiple client instances, just as I can with the Node SDK.

Describe alternatives you've considered
I can think of a couple alternate approaches:

  1. Allow the SDK user to destroy the existing client instance and create a new one to replace it
  2. Allow the SDK user to update the client configuration options (including mobileKey) for a client that's already been initialized

Either of these solutions would work for me as well. I'm not sure which of the three options is easiest to implement.

Additional context
I'm really enjoying working with this SDK - thanks so much for making it available!

Update User Properties after configuration

Is your feature request related to a problem? Please describe.
I want a way to update user properties after configuring the client.

Describe the solution you'd like
Just like the e.g ios SDK's updateUser

Describe alternatives you've considered
I don't know of an alternative, is there any way to do this at the moment?

Cant initialize client

Simply doing the follow breaks (ios and android):

 client = new LDClient();

resulting error:
Screen Shot 2021-04-14 at 12 47 42 PM

react-native-client-sdk version: 4.1.0
React native version: 0.64
xcode version: 12.4

NativeModules is an empty object for me here

No such module 'LaunchDarkly'

Is this a support request?
Yes

Describe the bug
I followed the guide on this. But unable to run the project.

To reproduce

  1. npm install --save launchdarkly-react-native-client-sdk
  2. react-native link launchdarkly-react-native-client-sdk
  3. add
use_frameworks!
pod 'LaunchDarkly', :git => 'https://github.com/launchdarkly/ios-client.git', :tag => '3.0.0-beta.3'

to the Podfile. And pod install.

Expected behavior
Build Successfully.

Result
But I got the error:
image

SDK version
react-native: 0.57.8
launchdarkly-react-native-client-sdk: 1.0.1
LaunchDarkly: :git => 'https://github.com/launchdarkly/ios-client.git', :tag => '3.0.0-beta.3'

Language version, developer tools
Xcode 10.1,

OS/platform
Swift 3.

Additional Info
I checked the Framework Search Paths of LaunchdarklyReactNativeClient.xcodeproj:
image

And I can find the LaunchDarkly under the Pods folder.

Duplicate module bundler error

Describe the bug
Duplicate module name error in bundler.
launchdarkly-react-native-client's package.json has react-native listed as a dependency and a peerDependency.
In a react native project, react-native should already be a project dependency. When bundling the app after adding launchdarkly-react-native-client we get a duplicate module error and the bundler fails.

Expected behavior
The package.json for launchdarkly-react-native-client should not have react-native as a dependency

Build fails: Undefined symbol

Describe the bug
The build fails and gives me 100 errors, all of them starting with Undefined symbol: ....

To reproduce

  1. Install LaunchDarklySDK following the steps in the Getting Started guide
  2. Build the app.

I found similar issue on StackOverflow

Expected behavior
Should make the build with success and SDK working in the app.

versions
launchdarkly-react-native-client-sdk 2.1.0
macOS Catalina 10.15.2
Xcode 11.3

Additional context
Log

Thanks for any help!

Apps using this SDK cannot be installed on Android 12 devices

Describe the bug
From Android Documentation:

If your app targets Android 12 and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported attribute for these app components.

launchdarkly-react-native-client-sdk depends on launchdarkly-android-client-sdk 2.14.1 which doesn't include this attribute (it was added on launchdarkly-android-client-sdk 3.0.1)

To reproduce
Install an app targeting Android 12 and using launchdarkly-react-native-client-sdk => App can't be installed

Expected behavior
The app installs properly on Android 12 devices

OS/platform
Android 12

Compatibility with React Native 0.60+

Is your feature request related to a problem? Please describe.

I would love to see the SDK support React-Native 0.60+

Describe the solution you'd like

We were forced to upgrade to React-Native 0.60 due to the Google Play Android restrictions now enforcing 64bit as of Aug 1 2019:
https://developer.android.com/distribute/best-practices/develop/64-bit

Describe alternatives you've considered
We have integrated the lib correctly but seeing errors listed below.
We are considering forking the library and making the modifications to support:
https://github.com/FreebirdRides/react-native-client-sdk

Additional context

Debug runtime error:
There's an error with React bridge when hot reloading a feature flag:
Screenshot_9_12_19__4_10_PM

Release build error:
❌ ld: library not found for -lLaunchdarklyReactNativeClient

Add Provider Wrapper like in launchdarkly-react-client-sdk

Is your feature request related to a problem? Please describe.
No.

Describe the solution you'd like
Will there be plans to add a Provider API for react native like there is for the regular react sdk.

import { withLDProvider } from 'launchdarkly-react-client-sdk';

Describe alternatives you've considered
N/A

Additional context
Add any other context about the feature request here.

client.boolVariation throws "TypeError: LaunchdarklyReactNativeClient.boolVariationFallback is not a function."

Describe the bug
On v4.x.x, when calling await client.boolVariation(flagName, false); I get the following warning: "TypeError: LaunchdarklyReactNativeClient.boolVariationFallback is not a function." and the flag isn't returned.

Works with v3.2.2.

To reproduce

  • Install launchdarkly-react-native-client-sdk v4.0.0 or higher
  • Call the client.boolVariation function inside React Native app

Expected behavior
No error is thrown and the flag is returned from client.boolVariation.

Logs

Possible Unhandled Promise Rejection (id: 0):
TypeError: LaunchdarklyReactNativeClient.boolVariationFallback is not a function. (In 'LaunchdarklyReactNativeClient.boolVariationFallback(flagKey, fallback)', 'LaunchdarklyReactNativeClient.boolVariationFallback' is undefined)
boolVariation@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:307598:69
fetchNewValue$@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:308016:71
tryCatch@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:25663:23
invoke@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:25836:32
tryCatch@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:25663:23
invoke@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:25736:30
http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:25766:19
tryCallTwo@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3623:9
doResolve@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3787:25
Promise@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:3646:14
callInvokeWithMethodAndArg@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:25765:33
enqueue@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:25770:157
http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:25787:69
fetchNewValue@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:308011:42
http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:308033:20
commitHookEffectListMount@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:20440:38
commitLifeCycles@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:20491:42
commitLayoutEffects@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:22775:29
invokeGuardedCallbackImpl@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:9999:21
invokeGuardedCallback@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:10093:42
commitRootImpl@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:22564:36
commitRootImpl@[native code]
unstable_runWithPriority@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:46622:30
commitRoot@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:22451:24
performSyncWorkOnRoot@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:21975:19
performSyncWorkOnRoot@[native code]
http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:13248:38
unstable_runWithPriority@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:46622:30
flushSyncCallbackQueueImpl@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:13243:28
flushSyncCallbackQueue@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:13232:35
batchedUpdates$1@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:21994:35
batchedUpdates@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:11248:36
_receiveRootNodeIDEvent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:11340:23
receiveTouches@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:11393:34
__callFunction@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2980:36
http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2708:31
__guard@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2931:15
callFunctionReturnFlushedQueue@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2707:21
callFunctionReturnFlushedQueue@[native code]

SDK version
Tried with v4.2.1, v4.1.2, v4.0.4, v4.0.0

OS/platform
iOS

App crashes in debug mode after a reload of the app

Is this a support request?
No

Describe the bug
Since LaunchDarklyReactNativeClient.swift inherits from RCTEventEmitter and somehow LD is synthesizing the bridge property somewhere that I can't find. On reload, this property is nil, hence causes the crash when it attempts to sendEvent while trying to register a listener

To reproduce

  1. Write code to register a listener in one of your screens that is launched as one of the first screens after opening the app.
  2. Build and run the app (The app should run fine)
  3. Open RN Developer Menu by shaking the device and hit Reload or CMD+R
  4. Result: app crash

Expected behavior
The app should not crash on reload. It should successfully register the listener once it has the bridge.

Logs
Don't have any.

SDK version
2.2.0

Language version, developer tools
Xcode 10.2.1
ReactNative: 0.59.10

OS/platform
iOS only

Additional context
N/A

Unable to compile on iOS

Hello!

I am unable to build the project on iOS. I am trying to get it built on a clean project with the following steps:

react-native init LaunchDarklyTest
cd LaunchDarklyTest
yarn add launchdarkly-react-native-client
react-native link launchdarkly-react-native-client
cd ios 
pod init

I change the Podfile to the following:

# Uncomment the next line to define a global platform for your project
use_frameworks!
platform :ios, '9.0'

target 'LaunchDarklyTest' do
  rn_path = '../node_modules/react-native'
  rn_darkly_path = '../node_modules/launchdarkly-react-native-client/ios'

  pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
  pod 'React', path: rn_path, subspecs: [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
  ]

  # React Native third party dependencies podspecs
  pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
  pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"

  #launchdarkly-react-native-client dependencies

  pod 'LaunchDarkly', :git => 'https://github.com/launchdarkly/ios-client.git', :branch => 'v3-beta'
  
  pod 'LaunchdarklyReactNativeClient', path: rn_darkly_path

end

as instructed in the docs, and run pod install.

I open LaunchDarklyTest.xcworkspace with Xcode and compile the project.

I then receive the following error:
image

My environment info:

React Native Environment Info:
    System:
      OS: macOS 10.14
      CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
      Memory: 31.83 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.12.0 - /usr/local/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 23, 24, 25, 26, 27, 28
        Build Tools: 22.0.1, 23.0.1, 25.0.0, 25.0.1, 25.0.2, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.1, 27.0.3, 28.0.2, 28.0.3
        System Images: android-23 | Google APIs Intel x86 Atom_64, android-24 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-26 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.2/10P107d - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.3 => 16.6.3
      react-native: 0.58.6 => 0.58.6
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

Android: registerAllFlagsListener is passing a stringified array instead of an array of strings to the given callback

Is this a support request?
No.

Describe the bug
On Android, the callback given to registerAllFlagsListener is receiving a stringified array of feature flags instead of an actual array of strings. This is inconsistent with iOS & the typescript definitions provided by the library.

See images below:

Type definition + example code:
Screen Shot 2021-09-03 at 10 36 09 am

Console output:
Screen Shot 2021-09-03 at 10 36 20 am

To reproduce
On a brand new app, initialise the LaunchDarkly SDK & use the following snippet:

client = new LaunchDarkly();
client.registerAllFlagsListener('ALL_FLAGS_LISTENER', (updatedFlags) => {
    console.log(typeof updatedFlags);
});

Then run the app on both iOS and Android and update a feature flag from the LaunchDarkly web app. The behaviour will differ between platforms.

Expected behavior
An array of strings representing which flags have changed should be passed in to the callback.

Logs
Non applicable.

SDK version

"launchdarkly-react-native-client-sdk": "5.0.0"

Language version, developer tools
Non applicable.

OS/platform

  • MacOS Big Sur
  • Android 9
  • Tested on both React Native 0.65.1 & 0.64.2

Type definitions for projects using Typescript

Is your feature request related to a problem? Please describe.
In React Native projects that use Typescript, importing the launchdarkly-react-native-client-sdk results in a type error:

Could not find a declaration file for module 'launchdarkly-react-native-client-sdk'.... implicitly has an 'any' type.

Describe the solution you'd like
I'm requesting an official type definition to be included with the LaunchDarkly SDK

Describe alternatives you've considered
I searched DefinitelyTyped for a community definition, but none exists.

Additional context
N/A

Error on pod install: "The following Swift pods cannot yet be integrated as static libraries: The Swift pod `LaunchDarkly` depends upon `DarklyEventSource`, which does not define modules"

Is this a support request?
No

Describe the bug
When following integration instructions for the SDK, the pod install step fails with the following error:

[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `LaunchDarkly` depends upon `DarklyEventSource`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

To reproduce

Within a React Native project:

  • yarn add launchdarkly-react-native-client-sdk
  • cd ios/
  • pod install

Expected behavior
When integrating the LaunchDarkly SDK for React Native apps, installing the requisite pods should succeed.

Logs
N/A

SDK version
I am using the latest as of the time of writing - version 2.0.2

Language version, developer tools
React Native version 0.61.1
CocoaPods version 1.8.3

OS/platform
MacOS Mojave 10.14.5

Additional context

Thank you!

React Native 0.64 support

On another issue it was mentioned another release w/ react native 0.64 support would be out fairly soon after 4.0.0 release.

Would you be able to provide an eta for it? Thanks!

Android - Config and identify same user with different properties on same client getAllFlag() wrong variation

Describe the bug

On LaunchDarkly I have two variations and two targeting rules

First one : If buildNumber >=1 serve Variation 1
Second one: Serve Variation 2

In our codebase we configure the user with all needed properties and we add the additional custom field buildNumber set to 1. Then call allFlags() on that client after having identified the user. I receive the Variation 1. (Note that I get the same result with using jsonVariation()

If I change the buildNumber to -1 and use identify, reuse the client and then call allFlags() I still get the variation 1.

But if I force close the app and a new initialization of the client is done, then I receive variation 2.

To reproduce
Setup two variations/targeting as described above.

const defaultLDOptions = {
      useReport: true,
      stream: false,
      disableBackgroundUpdating: true,
      mobileKey,
    };
    const ldClient = new LDClient();
    const ldUser = {
      ...requiredLDUserProps,
      custom: {
        buildNumber: 1,
      },
    };
    await ldClient.configure(defaultLDOptions, ldUser);
    const flags = await ldClient.allFlags();
    console.log(flags); //Variation 1

    await ldClient.identify({ ...ldUser, custom: { buildNumber: -1 } });
    const flagsRound2 = await ldClient.allFlags();
    console.log(flagsRound2); //Variation 1 but should be Variation 2

Expected behavior

Flags are updated appropriately returned when reidentifying the user with different values after a config.

Upon writing this issue I also fixed my problem by identifying the user right after the config with said user. It seems weird doing the config and identify with the same user, feels like making the call twice. Maybe it should be more explicit in the documentation in that case if it is expected to get appropriate results.

SDK version
3.2.1

Language version, developer tools
ReactNative 0.63.3

OS/platform
Android maybe iOS too, not tested.

Pod spec error on pod install

Describe the bug
Tried to integrate the sdk into react-native app, did a yarn add of the library, later moved to the ios directory and tried to do a pod install, got greeted with different errors, first it stated that the LaunchDarkly dependency was not available, so I added it following the documentation:

pod 'LaunchDarkly', '4.3.2'

Tried pod install again, this time got a version error:

[!] CocoaPods could not find compatible versions for pod "LaunchDarkly":
  In Podfile:
    LaunchdarklyReactNativeClient (from `../node_modules/launchdarkly-react-native-client-sdk/ios`) was resolved to 2.2.0, which depends on
      LaunchDarkly (= 4.4.0)

None of your spec sources contain a spec satisfying the dependency: `LaunchDarkly (= 4.4.0)`.

Updated the dependecy to 4.4.0, still not working...

SDK version

"launchdarkly-react-native-client-sdk": "^2.2.0"

Versions
System:
OS: macOS 10.15.2
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 5.63 GB / 32.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.10.0 - ~/.volta/tools/image/node/12.10.0/6.10.3/bin/node
Yarn: 1.19.2 - ~/.volta/tools/image/yarn/1.19.2/bin/yarn
npm: 6.10.3 - ~/.volta/tools/image/node/12.10.0/6.10.3/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 27, 28, 29
Build Tools: 27.0.3, 28.0.3, 29.0.0
System Images: android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.4 => 0.61.4

Upgrade The Version for LaunchDarkly

I found the LaunchDarkly version for react-native does not update for a long time. Even the react-native version updates, but the dependence for iOS doesn't update. Is there a plan to update it ? The version is 4.5.0 now.
截屏2021-03-18 上午9 08 32

iOS Crash LeanplumRequest.m line 116

Describe the bug
There's a crash that's been present for 6 months or more.

I think it's caused by the RN client not calling the SDK on the right thread / queue (see logs).

To reproduce
Too hard to reproduce.

Expected behavior
The SDK to not crash.

Logs
+[LeanplumRequest generateUUID]

Crashed: NSOperationQueue 0x280c2f020 (QOS: UNSPECIFIED)
0  libobjc.A.dylib                0x19139b530 objc_msgSend + 16
1  Foundation                     0x192bf6830 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] + 700
2  Foundation                     0x192b49c58 -[NSObject(NSKeyValueObservingPrivate) _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:] + 648
3  CoreFoundation                 0x1920a524c -[CFPrefsSource forEachObserver:] + 260
4  CoreFoundation                 0x1920a6cb0 -[CFPrefsSource _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:] + 76
5  CoreFoundation                 0x1921e6ffc ___CFPrefsDeliverPendingKVONotificationsGuts_block_invoke + 408
6  CoreFoundation                 0x192107e10 __CFDictionaryApplyFunction_block_invoke + 24
7  CoreFoundation                 0x1921d18dc CFBasicHashApply + 116
8  CoreFoundation                 0x192107dec CFDictionaryApplyFunction + 168
9  CoreFoundation                 0x1921e0710 _CFPrefsDeliverPendingKVONotificationsGuts + 260
10 CoreFoundation                 0x192126d70 __108-[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:]_block_invoke + 304
11 CoreFoundation                 0x192126794 normalizeQuintuplet + 340
12 CoreFoundation                 0x192094e74 -[_CFXPreferences(SearchListAdditions) withSearchListForIdentifier:container:cloudConfigurationURL:perform:] + 108
13 CoreFoundation                 0x192097e8c -[_CFXPreferences setValue:forKey:appIdentifier:container:configurationURL:] + 92
14 CoreFoundation                 0x1921e5460 _CFPreferencesSetAppValueWithContainerAndConfiguration + 132
15 Foundation                     0x192b44a08 -[NSUserDefaults(NSUserDefaults) setObject:forKey:] + 64
16 Leanplum                       0x103747fd4 +[LeanplumRequest generateUUID] + 116 (LeanplumRequest.m:116)
17 Leanplum                       0x103748d50 __32-[LeanplumRequest sendRequests:]_block_invoke + 261 (LeanplumRequest.m:261)
18 Foundation                     0x192c0def8 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16
19 Foundation                     0x192b1a3e0 -[NSBlockOperation main] + 72
20 Foundation                     0x192b198c8 -[__NSOperationInternal _start:] + 740
21 Foundation                     0x192c0fc7c __NSOQSchedule_f + 272
22 libdispatch.dylib              0x191be8a38 _dispatch_call_block_and_release + 24
23 libdispatch.dylib              0x191be97d4 _dispatch_client_callout + 16
24 libdispatch.dylib              0x191b8e018 _dispatch_continuation_pop$VARIANT$mp + 412
25 libdispatch.dylib              0x191b8d6dc _dispatch_async_redirect_invoke + 600
26 libdispatch.dylib              0x191b9a02c _dispatch_root_queue_drain + 372
27 libdispatch.dylib              0x191b9a8d0 _dispatch_worker_thread2 + 128
28 libsystem_pthread.dylib        0x191dc91b4 _pthread_wqthread + 464
29 libsystem_pthread.dylib        0x191dcbcd4 start_wqthread + 4

SDK version
3.1.1

Language version, developer tools
n/a

OS/platform
iOS 12.3.1

Additional context
It's definitely an issue where the RN bridge uses an operation queue that's not compatible with the SDK or Foundation APIs. This is usually resolved by dispatching to the main thread for example.

Can't find variable: promise

Is this a support request?
This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the SDK code. If you're not sure whether the problem you are having is specifically related to the SDK, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going here and clicking "submit a request", or by emailing [email protected].

Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.

Describe the bug
When calling isInitialized to see if it is initialized on Android, we are getting "can't find variable. promise" And yes it is missing

To reproduce
Call isInitialized on ldClient instance
Expected behavior
Please define promise and fix it.

Logs
If applicable, add any log output related to your problem.

SDK version
3.2.0

Language version, developer tools
Java, Android
Screen Shot 2020-08-25 at 7 58 01 PM

OS/platform
Android

Additional context
Add any other context about the problem here.

LaunchDarklyReactNativeClient fails to compile, `React/RCTBridge.h file not found`

Is this a support request?
No, it is specific to this SDK

Describe the bug
After following the integration guide, iOS still fails to compile. There is a warning when XCode starts the task, BuildtargetLaunchDarklyReactNativeClient, which says that it is missing the dependency target React.
Shortly thereafter, the step fails and errors are logged that the React/RCTBridge header cannot be found. (see attached screenshot).
We have attempted manually linking the React dependency, as well as verifying that the header search values are as expected (per various similar issues) in both the targets for LaunchDarklyReactNativeClient as well as our own.

To reproduce
Update our Podfile according to the SDK instructions
Clean Pods/ directory
Run rm Podfile.lock && bundle exec pod install
Clean derived data directory
Restart XCode
Clean project and build.

Expected behavior
Build passes

Logs
See attached screenshot

SDK version
2.0.0

Language version, developer tools
XCode 10.2.1
React-Native 59.9
Cocoapods 1.5.3
Ruby 2.3.7p456
Swift 5.0

OS/platform
Mac OS Mojave 10.14.5
iOS 12.2
XCode 10.2.1

Screen Shot 2019-07-12 at 12 11 31 PM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.