UNPKG

react-native-slang

Version:

React native interface for Slang

87 lines (56 loc) 2.19 kB
# react-native-slang Slang integration for React Native Apps built for Android. ## Getting started ` npm install react-native-slang --save` ### Automatic installation ` react-native link react-native-slang` ### Manual installation #### Android 1. Open up `android/app/src/main/java/[...]/MainActivity.java` - Add `import com.reactlibrary.RNSlangPackage;` to the imports at the top of the file - Add `new RNSlangPackage()` to the list returned by the `getPackages()` method 2. Append the following lines to `android/settings.gradle`: ``` include ':react-native-slang' project(':react-native-slang').projectDir = file('../node_modules/react-native-slang/android') ``` 3. Insert the following lines inside the dependencies block in `android/app/build.gradle`: ``` implementation project(':react-native-slang') ``` ### Steps required In project level build.gradle add ``` allprojects { repositories { ... maven { url "http://maven.slanglabs.in:8080/artifactory/gradle-release" } ... ``` ## Integrating slang buddy on to your react-native app ### Prerequisites Before starting with integrating slang with your react-native app, you must create a slang buddy in our console and configure it. Slang console - https://console.slanglabs.in/home Slang console guide - https://docs.slanglabs.in/slang/developer-guide/slang-developer-guide ### Usage In your App.js or equivalent file , initialize the slang trigger with the following ``` import { Slang } from 'react-native-slang'; // Initialize slang Slang.initialize( "<your buddy id>", "<your api key>", { "locale": "LOCALE_ENGLISH_IN", // Other possible values: LOCALE_HINDI_IN, LOCALE_ENGLISH_US "position": "CENTER_BOTTOM", // Other possible values: LEFT_TOP, CENTER_TOP, RIGHT_TOP, CENTER, LEFT_BOTTOM, RIGHT_BOTTOM etc. }, () => { console.log("Slang initialized successfully") }); // Listen to slang intent actions. Slang.setIntentActionListener((action) => { console.log(action); Slang.notifyActionCompleted(true); }); ``` Go to https://docs.slanglabs.in/slang/ to know more.