0.0.14 • Published 5 years ago

launch-darkly-react-native v0.0.14

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

launch-darkly-react-native

React Native wrapper over LaunchDarkly SDK's for iOS and Android.

LaunchDarkly

Native iOS SDK

Native Android SDK

Getting started

$ npm install launch-darkly-react-native --save

or

$ yarn add launch-darkly-react-native --save

Mostly automatic installation

$ react-native link launch-darkly-react-native

iOS:

Add the following line to your podfile:

pod 'LaunchDarkly'

and run

pod install

Android:

/!\ The Android project has not been updated from the original fork and has not been tested yet!

Add line bellow at the bottom of your app/build.gradle

configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.1' }

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_moduleslaunch-darkly-react-native and add RNLaunchDarkly.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNLaunchDarkly.a to your project's Build PhasesLink Binary With Libraries

Android

/!\ The Android project has not been updated from the original fork and has not been tested yet!

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.reactlibrary.RNLaunchDarklyPackage; to the imports at the top of the file
  • Add new RNLaunchDarklyPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':launch-darkly-react-native'
    project(':launch-darkly-react-native').projectDir = new File(rootProject.projectDir, 	'../node_modules/launch-darkly-react-native/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':launch-darkly-react-native')
  3. Add line bellow at the bottom of your app/build.gradle
    configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.1' }

Usage

import LaunchDarkly from 'launch-darkly-react-native';

const user = {
  key: 'key',
  email: 'email@example.com', // optional
  firstName: 'firstname', // optional
  lastName: 'lastname', // optional
  isAnonymous: false, // optional
};

// init native SDK with api key and user object
LaunchDarkly.configure('apiKey', user);

// get boolean feature flag value
LaunchDarkly.boolVariation('featureFlagName', (showFeature) => {
  console.log('Show feature:', showFeature);
});

// get string feature flag value
LaunchDarkly.stringVariation('featureFlagName', 'fallback', (value) => {
  console.log('String value:', value);
});

// adds listener which is called every time given feature flag value is changed
// callback is called with flagName string, so you will have to call LaunchDarkly.boolVariation()
// to get new feature flag value
LaunchDarkly.addFeatureFlagChangeListener('flagName', () => {
  console.log('callback');
});

// removes all onFeatureFlagChange listeners
LaunchDarkly.unsubscribe();
0.0.14

5 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago