Skip to content

Commit

Permalink
Release v9.3.0
Browse files Browse the repository at this point in the history
Release v9.3.0
  • Loading branch information
yeskay-zohocorp committed Jun 28, 2024
1 parent 9fc96c7 commit 9bf3d5c
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![SupportedLanguages](https://img.shields.io/badge/Platforms-iOS%20%7C%20%20Android-green.svg)](https://www.zoho.com/salesiq/help/developer-section/react-native-sdk-installation.html) [![Version](https://img.shields.io/badge/version-9.2.1-blue.svg)](https://mobilisten.io/) [![Mobilisten NPM CD](https://github.com/zoho/SalesIQ-Mobilisten-ReactNative/workflows/Mobilisten%20NPM%20CD/badge.svg)](https://github.com/zoho/SalesIQ-Mobilisten-ReactNative/actions)
[![SupportedLanguages](https://img.shields.io/badge/Platforms-iOS%20%7C%20%20Android-green.svg)](https://www.zoho.com/salesiq/help/developer-section/react-native-sdk-installation.html) [![Version](https://img.shields.io/badge/version-9.3.0-blue.svg)](https://mobilisten.io/) [![Mobilisten NPM CD](https://github.com/zoho/SalesIQ-Mobilisten-ReactNative/workflows/Mobilisten%20NPM%20CD/badge.svg)](https://github.com/zoho/SalesIQ-Mobilisten-ReactNative/actions)

# React Native module for SalesIQ Mobilisten SDK

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ repositories {
dependencies {
implementation 'com.facebook.react:react-native:+'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
api 'com.zoho.salesiq:mobilisten:8.0.1'
api 'com.zoho.salesiq:mobilisten:8.0.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import com.zoho.livechat.android.modules.common.DataModule;
import com.zoho.livechat.android.modules.common.ui.LauncherUtil;
import com.zoho.livechat.android.modules.common.ui.lifecycle.SalesIQActivitiesManager;
import com.zoho.livechat.android.modules.common.ui.result.entities.SalesIQError;
import com.zoho.livechat.android.modules.knowledgebase.ui.entities.Resource;
import com.zoho.livechat.android.modules.knowledgebase.ui.entities.ResourceCategory;
import com.zoho.livechat.android.modules.knowledgebase.ui.entities.ResourceDepartment;
Expand Down Expand Up @@ -592,7 +593,7 @@ public static void showLauncher(final String mode) {

@ReactMethod
public static void updateListener(final String listener) {

}

@ReactMethod
Expand Down Expand Up @@ -1168,6 +1169,35 @@ public void onInitError() {
}
}

@ReactMethod
void present(final String tabString, final String id, final Callback callback) {
HANDLER.post(() -> {
ZohoSalesIQ.Tab tab = getTab(tabString);
ZohoSalesIQ.present(tab, id, result -> {
if (callback != null) {
if (result.isSuccess()) {
callback.invoke(null, result.getData());
} else {
SalesIQError error = result.getError();
callback.invoke(getErrorMap(error.getCode(), error.getMessage()), null);
}
}
});
});
}

private static ZohoSalesIQ.Tab getTab(String tab) {
ZohoSalesIQ.Tab tabType = null;
if (tab != null) {
if (Tab.CONVERSATIONS.name.equals(tab)) {
tabType = ZohoSalesIQ.Tab.Conversations;
} else if (Tab.KNOWLEDGE_BASE.name.equals(tab) || Tab.FAQ.name.equals(tab)) {
tabType = ZohoSalesIQ.Tab.KnowledgeBase;
}
}
return tabType;
}

public static void eventEmitter(String event, Object value) {
if (reactContext != null && hasAnyEventListeners) {
LiveChatUtil.log("eventEmitter, Send event: " + event);
Expand Down Expand Up @@ -1735,6 +1765,63 @@ static void showFeedbackUpToDuration(final int duration) {
ZohoSalesIQ.Chat.showFeedback(duration);
}

@ReactMethod
static void startNewChat(final String question, final String customChatId, final String departmentName, final Callback callback) {
final Callback[] finalCallback = {callback};
ZohoSalesIQ.Chat.start(question, customChatId, departmentName, result -> {
if (finalCallback[0] != null) {
if (result.isSuccess()) {
VisitorChat visitorChat = result.getData();
WritableMap visitorMap = getChatMapObject(visitorChat);
finalCallback[0].invoke(null, visitorMap);
} else {
SalesIQError error = result.getError();
finalCallback[0].invoke(getErrorMap(error.getCode(), error.getMessage()), null);
}
}
finalCallback[0] = null;
});
}

@ReactMethod
static void startNewChatWithTrigger(final String customChatId, final String departmentName, final Callback callback) {
final Callback[] finalCallback = {callback};
ZohoSalesIQ.Chat.startWithTrigger(customChatId, departmentName, result -> {
if (finalCallback[0] != null) {
if (result.isSuccess()) {
VisitorChat visitorChat = result.getData();
WritableMap visitorMap = getChatMapObject(visitorChat);
finalCallback[0].invoke(null, visitorMap);
} else {
SalesIQError error = result.getError();
finalCallback[0].invoke(getErrorMap(error.getCode(), error.getMessage()), null);
}
}
finalCallback[0] = null;
});
}

@ReactMethod
static void getChat(final String chatId, final Callback callback) {
ZohoSalesIQ.Chat.get(chatId, result -> {
if (callback != null) {
if (result.isSuccess()) {
VisitorChat visitorChat = result.getData();
WritableMap visitorMap = getChatMapObject(visitorChat);
callback.invoke(null, visitorMap);
} else {
SalesIQError error = result.getError();
callback.invoke(getErrorMap(error.getCode(), error.getMessage()), null);
}
}
});
}

@ReactMethod
static void setChatWaitingTime(final int seconds) {
ZohoSalesIQ.Chat.setWaitingTime(seconds);
}

public static final String RESOURCE_ARTICLES = "RESOURCE_ARTICLES"; // No I18N

private @Nullable ZohoSalesIQ.ResourceType getResourceType(String value) {
Expand Down Expand Up @@ -1927,7 +2014,7 @@ static String convertToCamelCase(String input) {
return camelCase.toString();
}

WritableMap getErrorMap(int code, String message) {
static WritableMap getErrorMap(int code, String message) {
WritableMap errorMap = new WritableNativeMap();
errorMap.putInt("code", code); // No I18N
errorMap.putString("message", message); // No I18N
Expand Down
16 changes: 16 additions & 0 deletions components/zohosalesiqJSWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ module.exports = {
initWithCallback: function (appKey, accessKey, callback) {
RNZohoSalesIQ.initWithCallback(appKey, accessKey, callback);
},
present: function(tab = null, id = null, callback = ()=>{}) {
RNZohoSalesIQ.present(tab, id, callback);
},
setChatTitle: function (title) {
RNZohoSalesIQ.setChatTitle(title);
},
Expand Down Expand Up @@ -148,6 +151,7 @@ module.exports = {
setQuestion: function (question) {
RNZohoSalesIQ.setQuestion(question);
},
// DEPRECATED
startChat: function (message) {
RNZohoSalesIQ.startChat(message);
},
Expand Down Expand Up @@ -293,6 +297,18 @@ module.exports = {
},
open: function (map) {
RNZohoSalesIQ.showPayloadChat(map);
},
start: function(question, customChatId = null, departmentName = null, callback = ()=>{}) {
RNZohoSalesIQ.startNewChat(question, customChatId, departmentName, callback);
},
startWithTrigger: function(customChatId = null, departmentName = null, callback = ()=>{}) {
RNZohoSalesIQ.startNewChatWithTrigger(customChatId, departmentName, callback);
},
setWaitingTime: function(seconds) {
RNZohoSalesIQ.setChatWaitingTime(seconds);
},
get: function(chatId, callback) {
RNZohoSalesIQ.getChat(chatId, callback);
}
},
sendEvent: function (eventName, ...values) {
Expand Down
71 changes: 71 additions & 0 deletions ios/RNZohoSalesIQ.m
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,77 @@ + (void)handleNotificationAction: (NSDictionary *) info response:(NSString *) re
[[ZohoSalesIQ Chat] showWithReferenceID:nil new:YES];
}

//MARK:- START CHAT API's
RCT_EXPORT_METHOD(startNewChat: (NSString *)question chatId:(NSString * _Nullable)chatId department:(NSString * _Nullable)department callback:(RCTResponseSenderBlock)callback){
[[ZohoSalesIQ Chat] startWithQuestion:question chatID:chatId department:department completion:^(id<SIQError> _Nullable error, SIQVisitorChat * _Nullable chat) {
if (callback) {
if(error != nil){
NSMutableDictionary *errorDictionary = [RNZohoSalesIQ getSIQErrorObject:error];
callback(@[errorDictionary, [NSNull null]]);
}else{
NSMutableDictionary *chatDict = [NSMutableDictionary dictionary];
chatDict = [RNZohoSalesIQ getChatObject:chat];
callback(@[[NSNull null], chatDict]);
}
}
}];
}

RCT_EXPORT_METHOD(startNewChatWithTrigger: (NSString * _Nullable)chatId department:(NSString * _Nullable)department callback:(RCTResponseSenderBlock)callback){
[[ZohoSalesIQ Chat] startWithTriggerWithChatID:chatId department:department completion:^(id<SIQError> _Nullable error, SIQVisitorChat * _Nullable chat) {
if (callback) {
if(error != nil){
NSMutableDictionary *errorDictionary = [RNZohoSalesIQ getSIQErrorObject:error];
callback(@[errorDictionary, [NSNull null]]);
}else{
NSMutableDictionary *chatDict = [NSMutableDictionary dictionary];
chatDict = [RNZohoSalesIQ getChatObject:chat];
callback(@[[NSNull null], chatDict]);
}
}
}];
}

RCT_EXPORT_METHOD(getChat: (NSString *)chatId callback:(RCTResponseSenderBlock)callback){
[[ZohoSalesIQ Chat] getWithChatID:chatId completion:^(id<SIQError> _Nullable error, SIQVisitorChat * _Nullable chat) {
if(error != nil){
NSMutableDictionary *errorDictionary = [RNZohoSalesIQ getSIQErrorObject:error];
callback(@[errorDictionary, [NSNull null]]);
}else{
NSMutableDictionary *chatDict = [NSMutableDictionary dictionary];
chatDict = [RNZohoSalesIQ getChatObject:chat];
callback(@[[NSNull null], chatDict]);
}
}];
}

RCT_EXPORT_METHOD(present: (NSString * _Nullable)tab referenceId:(NSString * _Nullable)referenceId callback:(RCTResponseSenderBlock)callback) {
NSNumber *tabNumber;
if ([tab isEqual: TAB_CONVERSATIONS]) {
tabNumber = [NSNumber numberWithInteger:0];
} else if ([tab isEqual:TAB_FAQ] || [tab isEqual:TAB_KNOWLEDGE_BASE]) {
tabNumber = [NSNumber numberWithInteger:1];
}

[ZohoSalesIQ presentWithTabBarItem:tabNumber referenceID:referenceId shouldShowListView:YES completion:^(id<SIQError> _Nullable error, BOOL success) {
if (callback) {
NSNumber *complete = [NSNumber numberWithBool:success];
if(error != nil){
NSMutableDictionary *errorDictionary = [RNZohoSalesIQ getSIQErrorObject:error];
callback(@[errorDictionary, @[complete]]);
} else {
callback(@[[NSNull null], @[complete]]);
}
}
}];
}


RCT_EXPORT_METHOD(setChatWaitingTime: (NSInteger)seconds){
[[ZohoSalesIQ Chat] setWaitingTimeWithUpTo:seconds];
}


//MARK:- CHAT END SESSION API
RCT_EXPORT_METHOD(endChat: (NSString *)ref_id){
[[ZohoSalesIQ Chat] endSessionWithReferenceID:ref_id];
Expand Down
2 changes: 1 addition & 1 deletion ios/RNZohoSalesIQ.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "RNZohoSalesIQ"
s.version = "9.0.3"
s.version = "9.1.0"
s.summary = "A React-Native module for the SalesIQ Mobilisten SDK"
s.description = "A React-Native module for the SalesIQ Mobilisten SDK"
s.homepage = "https://zoho.com"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-zohosalesiq-mobilisten",
"version": "9.2.1",
"version": "9.3.0",
"description": "A React Native module for the ZohoSalesIQ Mobilisten SDK",
"bugs": {
"email": "[email protected]"
Expand Down

0 comments on commit 9bf3d5c

Please sign in to comment.