Wrapper for Kustomer SDK v2.0 for react native

Overview

Kustomer SDK V2 React Native

last-commit repo-size license npm-version

This is a wrapper for Kustomer v2 Sdk for react native. This implements the kustomer v2 for android and ios. Functions available for android and ios are available on react native.

Getting started

$ npm install react-native-kustomer-sdk-v2 --save

or

$ yarn add react-native-kustomer-sdk-v2

Requirements

  • Android minSdkVersion 21
  • iOS level 11

Android ( Important )

For android to register the api key

Add the following dependancies in build.gradle (App)

dependencies {
  ...
  implementation 'com.kustomer.chat:ui:2.9.2'
  ...
}

Add the code at last inside onCreate() in MainApplication.java

//MainApplication.java
//Add these import files
import kotlin.jvm.functions.Function1;
import com.kustomer.ui.KustomerOptions;
import com.reactnativekustomersdk.KustomerSdkPackage;
import com.kustomer.ui.Kustomer;  // Added for customer
import android.widget.Toast;
import com.kustomer.core.models.KusResult;
import kotlin.Unit;

...

public  void  onCreate()  {
...
	try {
	    Kustomer.Companion.init(this, "Enter-api-key-here", (KustomerOptions) null, (result) -> {
		    return Unit.INSTANCE;
		});
	}
	catch (AssertionError e) {
		Toast toast= Toast.makeText(getApplicationContext(),"API KEY IS INVALID",Toast.LENGTH_SHORT);
	    toast.show();
	}
}// onCreate closing bracket

The above code will show the toast if the API key is invalid.

In case of allowBackup error

Either make following changes in AndroidManifest.xml

//This is preffered because it overrides all sub androidManifest files with allowBackup true.
<manifest
	...
	xmlns:tools="http://schemas.android.com/tools"
>
	...
	<application
		...
		tools:replace="android:allowBackup"
	>

or

following changes in the AndroidManifest.xml file

	...
	<application
		...
		android:allowBackup="true"  //Change from false to true
	>

To read more about allowBackup.

Usage

Import the library to use its methods:

import * as KustomerSDK from "react-native-kustomer-sdk-v2";
or
import { open, login, logout } from "react-native-kustomer-sdk-v2";

Call initialize function at start in react native with the api key to register the Api key for iOS.

import { initialize } from "react-native-kustomer-sdk-v2";
...
initialize('Enter-API-Key'); // Add this when the app will mount
import * as KustomerSDK from "react-native-kustomer-sdk-v2";
...
KustomerSDK.initialize('Enter-API-Key'); // Add this when the app will mount

iOS

After installing the react-native-kustomer-sdk-v2 do pod install inside the ios folder.

pod install 

Methods

  • initialize(apiKey: String): Promise<number>

Initializes the apiKey to customer sdk. It is only required for ios and would cause no side effects on android.

KustomerSDK.initialize('Enter-API-Key').then(...);
  • isLoggedIn(email: String): Promise<number>

Calls the isLoggedIn function in the kustomer sdk. It checks whether the use is logged in.

KustomerSDK.isLoggedIn('email').then(...);
  • logIn(jwt: String): Promise<number>

Calls the logIn function in the kustomer sdk. It checks whether the use is logged in. To generate the jwt token use this code

KustomerSDK.logIn('Enter-JWT-token here').then(...);
  • logOut(): Promise<number>

Calls the logOut function in the kustomer sdk. It checks whether the user is logged in.

KustomerSDK.logOut().then(...);
  • open(type: openTypes): Promise<number>

Calls the open function in the kustomer sdk. Open the chat with one of the following types.

KustomerSDK.open('default').then(...);
type  openTypes  =  'default'  |  'chat_kb'  |  'chat_only'  |  'kb_only';
  • openNewConversation(initialMessage: string, animated?:boolean): Promise<string>

Calls the openNewConversation function in the kustomer sdk. Open the conversation with initial Message. Animated param is only available for iOS.

KustomerSDK.openNewConversation('intial_message').then(...); //Android
KustomerSDK.openNewConversation('intial_message',true).then(...); //iOS
  • openConversationByID(conversationID: string): Promise<string>

Calls the openConversationByID function in the kustomer sdk. Open the conversaton by id.

KustomerSDK.openConversationByID('id').then(...);
  • getUnreadCount(): Promise<number>

Calls the getUnreadCount function in the kustomer sdk. Returns the number unreadMessages.

KustomerSDK.getUnreadCount().then(...);
  • openKBbyID(kbID:string): Promise<boolean>

Calls the openKBbyID function in the kustomer sdk. Opens the knowledge base by id.

KustomerSDK.openKBbyID('kbid').then(...);
  • setActiveAssistant(assistantID:string): Promise<boolean>

Calls the setActiveAssistant function in the kustomer sdk. Sets the active assistant to the assistantID.

KustomerSDK.setActiveAssistant('assistantID').then(...);
  • getOpenConversationCount(): Promise<boolean>

Calls the getOpenConversationCountfunction in the kustomer sdk. Check the kustomer documentation for more description.

KustomerSDK.getOpenConversationCount().then(...);
  • closeChat(): Promise<boolean> | void

Calls the closeChat function in the kustomer sdk. Closes the chat. Only available for iOS.

KustomerSDK.closeChat().then(...);
  • chatVisible(): Promise<boolean> | void

Calls the chatVisiblefunction in the kustomer sdk. Returns if the chat is visible. Only available for iOS.

KustomerSDK.chatVisible().then(...);

Manual Installation

Android

Gradle

Include the library in your android/app/build.gradle:

implementation 'com.kustomer.chat:ui:2.9.+'

iOS

CocoaPods

The preferred installation method is with CocoaPods. Add the following to your Podfile:

pod 'KustomerChat'

Contributing

To contribute fork repository and make the nessecary changes. Raise a PR for the same. Mention iOS/Android/RN in the PR. Mention fix/feature/refactor in the PR.

Errors

In case of error please raise a issue.

While development do following if error occurs.

  • Set android:allowBackup="true" in the AndroidManifest.xml file (Android)
  • comment flipper in the Podfile (iOS)
  • add use_framework! in the Podfile (iOS)
You might also like...
NativeScript empowers you to access native platform APIs from JavaScript directly. Angular, Capacitor, Ionic, React, Svelte, Vue and you name it compatible.
NativeScript empowers you to access native platform APIs from JavaScript directly. Angular, Capacitor, Ionic, React, Svelte, Vue and you name it compatible.

NativeScript empowers you to access native APIs from JavaScript directly. The framework currently provides iOS and Android runtimes for rich mobile de

馃殌 React Native Segmented Control, Pure Javascript for iOS and Android
馃殌 React Native Segmented Control, Pure Javascript for iOS and Android

Installation Add the dependency: npm i react-native-segmented-control-2 Peer Dependencies Zero Dependency 馃コ Usage Import import SegmentedControl from

Library to read incoming SMS in Android for Expo (React Native)

react-native-expo-read-sms Maintainers maniac-tech Active maintainer Installation Install this in your managed Expo project by running this command: $

An Animated Scrolling View for React Native applications, supported on both iOS and Android

react-native-focused-scroll An Animated Scrolling View for React Native applications, supported on both iOS and Android Preview react-native-focus-scr

 A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.
A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.

Expo Music Picker A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library. Supp

GeckoView implementation on android for React Native.

react-native-geckoview A fully functional implementation of GeckoView on android for react native. The component supports two-way messaging similar to

A simple Android app to demonstrate the use of Hover SDK for M-PESA Send Money while offline. This SDK does not require an internet connection, it automates USSD sessions in the background of an android application.

HoverSDKDemo Hover SDK is an Android SDK that lets mobile developers to add money features to the applications. This SDK does not require an internet

Unity-Android-SDK-Plugins - Android SDK/Library/Plugins (aar) for Unity Developers

Unity Android SDK Plugins Unity Android SDK Plugins is an Open Source project th

A Python native extension written in Kotlin Native

Kotlin Python Ext This is a proof of concept for a Python extension in Kotlin. It is recommended to read the Official Python C API Documentation befor

Owner
Shivam Rawat
May geeks rule the world
Shivam Rawat
React-native-user-interface - Change React Native userinterface at runtime

react-native-user-interface change RN userinterface at runtime. Installation npm

Ahmed Eid 0 Jan 11, 2022
Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in the official package.

@mccsoft/react-native-matomo Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in th

MCC Soft 4 Dec 29, 2022
Make SIP calls from react-native using Linphone SDK

react-native-sip Make SIP calls from react-native using Linphone SDK Installation npm install react-native-sip Usage import { multiply } from "react-n

Woonivers 2 Jun 30, 2022
React Native Stone SDK Implementation (Support for both Mobile and POS versions)

react-native-stone-pos Stone Android POS Native Module Installation Stone has a private packageCloud repository, so we need to have your token before

8Sistemas 9 Dec 10, 2022
Initiate immediate phone call for React Native on iOS and Android.

react-native-immediate-call-library Initiate immediate phone call for React Native on iOS and Android. Getting started Using npm: npm install react-na

null 7 Sep 7, 2022
Simple library to decompress files .zip, .rar, .cbz, .cbr in React Native.

Uncompress React Native Simple library to decompress files .zip, .rar, .cbz and .cbr in React Native. Installation yarn add uncompress-react-native o

Adriano Souza Costa 40 Nov 24, 2022
A react native interface for integrating payments using PayPal

react-native-paypal Getting started Installation npm install react-native-paypal Android Specific Add this to your build.gradle maven { url "https:

eKreative 14 Sep 25, 2022
A 2020s compatible React Native keyboard avoiding view for Android and iOS that just works.

react-native-keyboard-shift Example Snack coming soon Until then: Clone this repo: git clone https://github.com/FullStackCraft/react-native-keyboard-s

Full Stack Craft 66 Aug 16, 2022
A demo for Android font typeface support in React Native!

A Step-by-step Guide to a Consistent Multi-Platform Font Typeface Experience in React Native Goal Be able to use font typeface modifiers such as fontW

Jules Sam. Randolph 53 Dec 23, 2022
A framework for building native applications using React

React Native Learn once, write anywhere: Build mobile apps with React. Getting Started 路 Learn the Basics 路 Showcase 路 Contribute 路 Community 路 Suppor

Meta 106.9k Jan 8, 2023