allprojects {
repositories {
jcenter()
……
maven { url 'https://jitpack.io' }
maven { url 'https://maven.google.com/' }
maven {
url "https://jfrog-artifact.revechat.com/artifactory/artifactory/"
}
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
…
maven { url 'https://jitpack.io' }
maven { url 'https://maven.google.com/' }
maven {
url "https://jfrog-artifact.revechat.com/artifactory/artifactory/"
}
}
}
package com.your_package_name;
import android.content.Intent;
import android.util.Log;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.revesoft.revechatsdk.model.VisitorInfo;
import com.revesoft.revechatsdk.ui.activity.ReveChatActivity;
import com.revesoft.revechatsdk.utils.ReveChat;
/**
* Native Module to communicate from react-native javascript code
* with REVEChat SDK
*/
public class REVEChatSDKModule extends ReactContextBaseJavaModule {
REVEChatSDKModule(ReactApplicationContext context) {
super(context);
}
@Override
public String getName() {
return "REVEChatSDKModule";
}
@ReactMethod
public void startChat(String accountId, String userName, String userEmail, String userPhoneNumber) {
Log.i("REVEChatSDKModule", "startChat: accountId " + accountId + " userName: " + userName+ " userEmail "+userEmail+" userPhoneNumber "+userPhoneNumber);
//Initializing with account id
ReveChat.init(accountId);
//creating visitor info
VisitorInfo visitorInfo = new VisitorInfo.Builder()
.name(userName)
.email(userEmail)
.phoneNumber(userPhoneNumber).build();
//set visitor info
ReveChat.setVisitorInfo(visitorInfo);
Intent intent = new Intent(getReactApplicationContext(), ReveChatActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getReactApplicationContext().startActivity(intent);
}
}
package [your_package_name]
import android.content.Intent
import android.util.Log
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.revesoft.revechatsdk.model.VisitorInfo
import com.revesoft.revechatsdk.ui.activity.ReveChatActivity
import com.revesoft.revechatsdk.utils.ReveChat
/**
* Native Module to communicate from react-native javascript code
* with REVEChat SDK
*/
class REVEChatSDKModule internal constructor(context: ReactApplicationContext?) : ReactContextBaseJavaModule(context) {
override fun getName(): String {
return "REVEChatSDKModule"
}
@ReactMethod
fun startChat(accountId: String, userName: String, userEmail: String, userPhoneNumber: String) {
Log.i(
"REVEChatSDKModule",
"startChat: accountId $accountId userName: $userName userEmail $userEmail userPhoneNumber $userPhoneNumber"
)
//Initializing with account id
ReveChat.init(accountId)
//creating visitor info
//creating visitor info
val visitorInfo: VisitorInfo = VisitorInfo.Builder()
.name(userName)
.email(userEmail)
.phoneNumber(userPhoneNumber).build()
//set visitor info
ReveChat.setVisitorInfo(visitorInfo)
val intent = Intent(reactApplicationContext, ReveChatActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
reactApplicationContext.startActivity(intent)
}
}
// React Native Sample Code
import {
NativeModules
} from 'react-native';
const {REVEChatSDKModule} = NativeModules;
<Button
title="Chat With Us"
onPress={() =>
{
REVEChatSDKModule.startChat('[account_id]', '[user_name]', '[user@email]', 'user_phone_number');
}
}
/>
<!-- screen background color -->
<color name="revechatsdk_layout_bg">#YourColor</color>
<!-- Button color -->
<color name="revechatsdk_btn_text">#YourColor</color>
<color name="revechatsdk_btn_bg">@color/revechatsdk_colorPrimary</color>
<!-- Chat screen colors -->
<color name="revechatsdk_color_chat_background">#YourColor</color>
<color name="revechatsdk_color_sending_msg_bg">#YourColor</color>
<color name="revechatsdk_color_receiving_msg_bg">#YourColor</color>
<color name="revechatsdk_shape_date_bubble_bg">#YourColor</color>
<!-- Chat action bar head text
<string name="revechatsdk_title_chat_window">YOUR MESSAGE TITLE</string>
Any questions? Please email us at [email protected]