TalkJS React Native SDK
Official TalkJS SDK for React Native
Note: This module does not support Expo (Managed Workflow) because it contains native code. If you use Expo's managed workflow, consider using @talkjs/expo which is identical to this module but with features that depend on native code removed.
You can also create a development build for your project using EAS Build or eject to the bare workflow.
What is TalkJS?
TalkJS lets you add user-to-user chat to your marketplace, on-demand app, or social platform. For more information, visit talkjs.com.
Don't hesitate to let us know if you have any questions about TalkJS.
Installation
Note: React Native CLI does not autolink libraries with native modules when those libraries are transitive dependencies. So you have to explicitly install the SDK's peer dependencies as shown below for the native modules to be loaded correctly
Npm:
npm install @talkjs/react-native @notifee/react-native @react-native-community/push-notification-ios @react-native-firebase/app @react-native-firebase/messaging react-native-webview
Yarn:
yarn add @talkjs/react-native @notifee/react-native @react-native-community/push-notification-ios @react-native-firebase/app @react-native-firebase/messaging react-native-webview
Usage
You can import the library in one of the following ways:
ES6 / TypeScript:
import * as TalkjsRn from '@talkjs/react-native';
CommonJS:
const TalkjsRn = require('@talkjs/react-native');
Then follow our React Native guide to start using TalkJS in your project.
TalkJS is fully forward compatible
We promise to never break API compatibility. We may at times deprecate methods or fields, but we will never remove them. If something that used to work stops working, then that's a bug. Please report it and we'll fix it asap.
The package is being released in a beta state. The reason for this is that there are things that one can do with the TalkJS JavaScript SDK that aren't possible with the React Native SDK. We will release v1.0.0 of this package once the two SDKs are similar in terms of features. This however does not take away from our commitment to always maintain backward compatibility. So you can be assured that the package is stable for production use.
Changelog
Note: These are only the changes that have an effect on the React Native package and its interface. TalkJS gets many improvements and fixes all the time. Consider subscribing to our changelog if you want to stay updated.
0.4.1
Fixes
-
Fix mark as read. This release ensures that messages are marked as read reliably as long as the chat is visible. If the app is in the background, or the chat is covered by the System UI (example: when receiving a call) then the messages won't be marked as read.
-
Fix rare crash on Android for SDK 28+ when the @react-navigation/native library is used.
0.4.0
- Fix Notifee display notification error.
With this release, we have updated the SDK's dependencies and peer dependencies to keep them up to date and also fix bugs in some of them.
As of npm v7, peer dependencies are installed by default so upgrading the TalkJS SDK should also upgrade the peer dependencies accordingly. For yarn users, you may have to update the packages individually as shown:
yarn upgrade @notifee/react-native@^5.3.0 @react-native-community/push-notification-ios@^1.10.1 @react-native-firebase/app@^14.11.0 @react-native-firebase/messaging@^14.11.0 react-native-webview@^11.21.2
These libraries are defined as peer dependencies rather than dependencies since they contain native code and currently, React Native does not auto link transitive dependencies.
The new version of the notifee library also eliminates the need to add the local maven repository manually to your project. You can remove the section below. (Your app will still build and run if you don't remove it)
maven {
url "$rootDir/../node_modules/@notifee/react-native/android/libs"
}
0.3.4
- Fix "Chat not found" error when joining as Guest.
0.3.3
- Fix regression in the support of devices with iOS 14 and lower.
0.3.2
- Fix Invariant Violation error due to transitive dependencies not being loaded.
To ensure the SDK's peer dependencies' native modules are loaded correctly, you have to explicitly install them as direct dependencies for your app/project. This is to ensure React Native CLI can autolink them. Below is how you'd accomplish that:
NPM:
npm install @notifee/react-native @react-native-community/push-notification-ios @react-native-firebase/app @react-native-firebase/messaging react-native-webview
Yarn:
yarn add @notifee/react-native @react-native-community/push-notification-ios @react-native-firebase/app @react-native-firebase/messaging react-native-webview
0.3.1
- Fix "Chat not found" bug when creating a new conversation.
0.3.0
When upgrading to this version, you'll need to update your android/build.gradle
file by adding the
following block to the repositories section of allprojects:
allprojects {
// ... you may have other items before the "repositories" section.
repositories {
// ... you will already have some local repositories defined ...
// ADD THIS BLOCK
maven {
url "$rootDir/../node_modules/@notifee/react-native/android/libs"
}
}
}
New Features
- Improved Android Notifications. They are now shown as Conversations and grouped accordingly. Images sent will also appear in the notifications.
- Added more configuration options on Android Channels (Reference).
- Improved Error Reporting.
- Add support for Guest Access through the addition of
asGuest
prop in Chatbox. - Enable capturing of keyup events in Chatbox through the
captureKeyboardEvents
andonKeyup
props. - Added the methods:
getText
andtypeText
to MessageField.
Changes
- Changed
oneOnOneId
to also acceptUser
Objects. - Changed
registerPushNotificationHandlers
to add support for iOS Permissions. - Changed
showFeedHeader
default tofalse
.
Fixes
- Fix bug when user and/or conversation synchronization were disabled.
Deprecated
- The following props in ConversationList:
feedConversationTitleMode
,thirdParties
,onBlur
andonFocus
. - The following props in Chatbox:
chatSubtitleMode
,chatTitleMode
,thirdParties
,translateConversations
,onBlur
andonFocus
.
0.2.1
- Fix bug in Chatbox when conversation synchronization was disabled.
0.2.0
- Added a ConversationList component.
- Added the messageField property to the Chatbox component
- Fix bug in ConversationBuilder.setAttributes that prevented setting a value to null or undefined after previously having given it a value.
- (iOS): Fix push notification registration token not getting received.
- (iOS): Fix zooming when messageField is clicked.
0.1.0
- Added the following components: Session, Chatbox and HtmlPanel.
- First release