
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
react-native-crisp-chat-sdk
Advanced tools
React-Native bridge for Crisp chat iOS and Android SDK's
React-Native bridge for Crisp chat iOS and Android SDK's
Install the library using either yarn or npm like so:
yarn add react-native-crisp-chat-sdk
npm install --save react-native-crisp-chat-sdk
This package supports Expo, however, since it's a wrapper on Crisp iOS and Android packages which are native libraries, it is not available in the Expo Go app. Using Crisp with Expo is explained here.
Installing Crisp Native SDK is mandatory:
cd ios && pod install
To enable your users to take and upload photos to the chat as well as download photos to their photo library, add the
Privacy - Camera Usage Description
(NSCameraUsageDescription) and Privacy - Photo Library Additions Usage Description
(NSPhotoLibraryAddUsageDescription) to your app's Info.plist.
⚠️ Adding Camera and Photo permissions is mandatory, NSCameraUsageDescription
and NSPhotoLibraryUsageDescription
in Info.plist
, to inform your users that you need to access to the Camera and Photo Library. You also have to enable "iCloud Documents" capability
Your website ID can be found in the Crisp App URL:
Crisp Website ID is an UUID like e30a04ee-f81c-4935-b8d8-5fa55831b1c0
When using Expo, push notifications are easy to set up and are covered in detail in the Expo installation guide.
When using React Native CLI, you will need to manually add custom handlers in the Android and iOS packages. The procedures are detailed in the Crisp Developer Hub for both iOS and Android.
You can view the example project for more usage.
setTokenId should be called before the chat has been presented. If you want to change the token after the chat has been presented, you need to call resetSession()
for the new token to come into effect.
When users logout from their account in your app, make sure to clear the token by calling setTokenId(null)
and then reset their local session by calling resetSession()
. This will not destroy the remote session with Crisp, it will only unbind the app from it. This session will be recovered when the user logs in again to their account, via their token.
Example of logout handling:
const userLogout = () => {
// Execute this sequence when your users are logging out
setTokenId(null); // 1. Clear the token value
resetSession(); // 2. Unbind the current session
};
import CrispChat, {
configure,
setUserEmail,
setUserNickname,
setUserPhone,
resetSession,
} from 'react-native-crisp-chat-sdk';
// ...
export default function App() {
// You must set your website ID before calling <CrispChat />
configure('YOUR_WEBSITE_ID');
// this should be user ID that way app will load previous user chats
setTokenId('abcd12345');
// Set user's info
setUserEmail('test@test.com');
setUserNickname('John Smith');
setUserPhone('+614430231224');
// Call session reset when user logs out
resetSession();
return <CrispChat />;
}
Use the Helpdesk APIs to open Crisp Helpdesk directly from your app.
import {
searchHelpdesk,
openHelpdeskArticle,
} from 'react-native-crisp-chat-sdk';
// Open Helpdesk search UI
searchHelpdesk();
// Open a specific Helpdesk article by slug and locale
openHelpdeskArticle('my-article-slug', 'en');
// Optionally override title/category displayed by Crisp
openHelpdeskArticle('my-article-slug', 'fr', 'title', 'category');
To get the required parameters for openHelpdeskArticle()
, follow these steps in your Crisp workspace:
For example, with URL: https://staging.crisp.help/fr/article/test-internal-link-2-6hkgyg/?bust=1755758362140
id
: 6hkgyg
(the article slug at the end)locale
: fr
(the language code in the URL path)title
: Optional - custom title to display (defaults to article's actual title)category
: Optional - custom category to display (defaults to article's actual category)openHelpdeskArticle(id, locale, title?, category?)
expects the article slug as id
and an IETF language tag for locale
(e.g. en
, fr
).Explicitly setting alternative languages from React is not currently supported. Nevertheless, the underlying SDK is able to select automatically the locale matching the one of device. The locale detection works out-of-the-box on Android. However, for the locale of the device to be detected on iOS apps, it has to be declared and setup in xcode as a supported language.
Here is a suggested method for adding languages support to your app in Xcode 13:
Start by adding support for your particular language in your project info (<yourProject>
> Info
> Localizations
>
+
). To make it active, you also need to create at least one dummy StringFile (File
> New
> File...
) with a
localized version matching the language you wish to add support to. After this step, if the locale of the device matches
the language you set up, it will be exposed by the app and chosen by the Crisp SDK. Note that alternative methods may
exist, but have not been tested regarding the locale detection of the Crisp SDK.
For iOS apps, debugging the preferred language exposed by your app can be achieved by adding the following line in your
AppDelegate.m file : NSLog(@"localeIdentifier: %@", [[NSLocale currentLocale] localeIdentifier]);
If for example, localeIdentifier: en_FR
or localeIdentifier: en_US
appears in your Xcode logs, then Crisp will be
displayed in english. If localeIdentifier: fr_FR
appears in your Xcode logs, it will be displayed in french.
CrispChatSDK.show()
CrispChatSDK.setTokenId('userID/GUID')
- Must be called before chat is presentedCrispChatSDK.pushSessionEvent(name: "Signup", color: CrispSessionEventColors.blue)
CrispChatSDK.setUserEmail('test@test.com')
CrispChatSDK.setUserNickname('John Doe')
CrispChatSDK.setUserPhone('003370123456789')
CrispChatSDK.setUserAvatar('https://pbs.twimg.com/profile_images/782474226020200448/zDo-gAo0_400x400.jpg')
CrispChatSDK.setSessionSegment('segment')
CrispChatSDK.setSessionString('key', 'value')
CrispChatSDK.setSessionBool('key', 'value')
CrispChatSDK.setSessionInt('key', 'value')
CrispChatSDK.resetSession()
- Use after logout or when changing tokensCrispChatSDK.configure('YOUR_WEBSITE_ID')
CrispChatSDK.searchHelpdesk()
CrispChatSDK.openHelpdeskArticle(id: string, locale: string, title?: string, category?: string)
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
FAQs
React-Native bridge for Crisp chat iOS and Android SDK's
The npm package react-native-crisp-chat-sdk receives a total of 866 weekly downloads. As such, react-native-crisp-chat-sdk popularity was classified as not popular.
We found that react-native-crisp-chat-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.