npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-kustomer-sdk-v2

v1.1.1

Published

Kustomer Sdk Library for react native based on v2.

Downloads

13

Readme

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)