react-native-wannatalk-core v1.1.0
react-native-wannatalk-core
Getting started
$ npm install react-native-wannatalk-core --save
Mostly automatic installation
$ react-native link react-native-wannatalk-core
iOS Setup
- Request WTService-Info.plist from wannatalk.ai and drag it into your application. When prompted, select "Copy items if needed" and continue.
Add below keys in your application's Info.plist
<key>NSPhotoLibraryUsageDescription</key> <string>To save in-chat photos and videos</string> <key>NSContactsUsageDescription</key> <string>To locate friends already on the Wannatalk network</string> <key>NSCameraUsageDescription</key> <string>To take photos and videos to send to friends in-chat</string> <key>NSLocationWhenInUseUsageDescription</key> <string>To display it in map</string> <key>NSMicrophoneUsageDescription</key> <string>To record live photos and movies</string>Add this line to your pod file
pod 'WTExternalSDK', :git =>'https://github.com/edzehoo/WannatalkAPI-iOS.git', :tag => '1.5.1'$ cd ios && pod install && cd ..$ react-native run-ios
To strip simulator architecture framework for your app submission
- Copy trim.sh file into your project folder.
- Create Run Script Phase in Build Phases of your application target.
- Paste
"$SRCROOT/trim.sh"inside the body of Run Script Phase. - Enable
Run script only when installingandShow environment variables in build log.
Android Setup
Request wannatalk-services.json from wannatalk.ai and drag it into your application
assetsdirectorySet
compileOptionsin your application build.gradle
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
...
}Enable
multiDexEnabledin your application build.gradleandroid { defaultConfig { // Enabling multidex support. multiDexEnabled true } ... }Set colorPrimary, colorPrimaryDark and colorAccent attributes in app's color.xml (src/main/res/values/colors.xml)
$ react-native run-android
Usage
import WannatalkCore from 'react-native-wannatalk-core';
import { NativeEventEmitter, NativeModules } from 'react-native'
const WannatalkCoreEmitter = new NativeEventEmitter(WannatalkCore)To link Wannatalk account
WannatalkCore.silentLogin("<user_identifier>", { displayname: "name", key1: "Value1", key2: "Value2"}, (success, error) => {
});Login events
componentDidMount() {
this.loginSubscription = WannatalkCoreEmitter.addListener('login-event', (data) => {
// this.setState({loggedIn: data.userLoggedIn});
})
}To check login status
WannatalkCore.isUserLoggedIn((userLoggedIn) => {
// this.setState({loggedIn: data.userLoggedIn});
})To unlink Wannatalk account
WannatalkCore.logout((success, error) => {
});HelpDesk
To load your organization profile
WannatalkCore.loadOrganizationProfile(true, (success, error) => {
});Collaboration
To view all chats
WannatalkCore.loadChatList(, (success, error) => {
});To view all users
WannatalkCore.loadUsers(, (success, error) => {
});Other
To show or hide guide button
WannatalkCore.ShowGuideButton(true); // default = trueTo enable or disable sending audio message
WannatalkCore.AllowSendAudioMessage(false); // default = YESTo show or hide add participants option in new ticket page and chat item profile page
WannatalkCore.AllowAddParticipants(false); // default = YESTo show or hide remove participants option in chat item profile
WannatalkCore.AllowRemoveParticipants(false); // default = NOTo show or hide welcome message
WannatalkCore.ShowWelcomeMessage(false); // default = NOTo show or hide Profile Info page
WannatalkCore.ShowProfileInfoPage(false); // default = YESTo create auto tickets:
Chat ticket will create automatically when auto tickets is enabled, otherwise default ticket creation page will popup
WannatalkCore.EnableAutoTickets(true); // default = NOTo show or hide close chat button in chat page
WannatalkCore.ShowExitButton(true); // default = NOTo show or hide participants in chat profile page
WannatalkCore.ShowChatParticipants(false); // default = YESTo enable or disbale chat profile page
WannatalkCore.EnableChatProfile(false); // default = YESTo allow modify in chat profile page
WannatalkCore.AllowModifyChatProfile(false); // default = YESTo set Inactive chat timeout:
Chat session will end if user is inactive for timeout interval duration. If timeout interval is 0, chat session will not end automatically. The default timout interval is 1800 seconds (30 minutes).
let timeoutInterval = 1800; // Default Value: 1800 seconds ~ 30 minutes
WannatalkCore.SetInactiveChatTimeoutInterval(timeoutInterval);