From 9bf3d5c71e46d5d87ed694d5c1e3f821834ac59d Mon Sep 17 00:00:00 2001 From: Kasiviswanath Senthilkumar Date: Fri, 28 Jun 2024 15:11:27 +0530 Subject: [PATCH] Release v9.3.0 Release v9.3.0 --- README.md | 2 +- android/build.gradle | 2 +- .../reactlibrary/RNZohoSalesIQ.java | 91 ++++++++++++++++++- components/zohosalesiqJSWrapper.js | 16 ++++ ios/RNZohoSalesIQ.m | 71 +++++++++++++++ ios/RNZohoSalesIQ.podspec | 2 +- package.json | 2 +- 7 files changed, 180 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 365ecbc..c9bec54 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/android/build.gradle b/android/build.gradle index 4d156e1..82c4779 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -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' } diff --git a/android/src/main/java/com/zohosalesiq/reactlibrary/RNZohoSalesIQ.java b/android/src/main/java/com/zohosalesiq/reactlibrary/RNZohoSalesIQ.java index e011956..a867839 100644 --- a/android/src/main/java/com/zohosalesiq/reactlibrary/RNZohoSalesIQ.java +++ b/android/src/main/java/com/zohosalesiq/reactlibrary/RNZohoSalesIQ.java @@ -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; @@ -592,7 +593,7 @@ public static void showLauncher(final String mode) { @ReactMethod public static void updateListener(final String listener) { - + } @ReactMethod @@ -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); @@ -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) { @@ -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 diff --git a/components/zohosalesiqJSWrapper.js b/components/zohosalesiqJSWrapper.js index 6dfdb7d..81c569d 100644 --- a/components/zohosalesiqJSWrapper.js +++ b/components/zohosalesiqJSWrapper.js @@ -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); }, @@ -148,6 +151,7 @@ module.exports = { setQuestion: function (question) { RNZohoSalesIQ.setQuestion(question); }, + // DEPRECATED startChat: function (message) { RNZohoSalesIQ.startChat(message); }, @@ -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) { diff --git a/ios/RNZohoSalesIQ.m b/ios/RNZohoSalesIQ.m index 05853f2..d383c96 100644 --- a/ios/RNZohoSalesIQ.m +++ b/ios/RNZohoSalesIQ.m @@ -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 _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 _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 _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 _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]; diff --git a/ios/RNZohoSalesIQ.podspec b/ios/RNZohoSalesIQ.podspec index 695731b..f03141e 100644 --- a/ios/RNZohoSalesIQ.podspec +++ b/ios/RNZohoSalesIQ.podspec @@ -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" diff --git a/package.json b/package.json index f3f7331..74f8256 100644 --- a/package.json +++ b/package.json @@ -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": "support@zohosalesiq.com"