From fcb0d04b531d33de2aebd4ac360c5f5549e495bf Mon Sep 17 00:00:00 2001 From: valliammai-sv Date: Fri, 29 Dec 2023 22:49:56 +0530 Subject: [PATCH] Release v7.0.0 --- README.md | 2 +- package.json | 2 +- plugin.xml | 4 +- src/android/ZohoSalesIQPlugin.java | 145 +++++++++++++++++++++++------ src/android/zohosalesIQ.gradle | 2 +- src/ios/ZohoSalesIQPlugin.m | 97 ++++++++++++++++++- www/ZohoSalesIQ.js | 49 +++++++--- 7 files changed, 255 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 76c5559..0e1625f 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/cordova-ionic-installation.html) [![Version](https://img.shields.io/badge/version-6.0.0-blue.svg)](https://mobilisten.io/) [![Mobilisten NPM CD](https://github.com/zoho/SalesIQ-Mobilisten-Cordova/workflows/Mobilisten%20NPM%20CD/badge.svg)](https://github.com/zoho/SalesIQ-Mobilisten-Cordova/actions?query=workflow%3A%22Mobilisten+NPM+CD%22) +[![SupportedLanguages](https://img.shields.io/badge/Platforms-iOS%20%7C%20%20Android-green.svg)](https://www.zoho.com/salesiq/help/developer-section/cordova-ionic-installation.html) [![Version](https://img.shields.io/badge/version-7.0.0-blue.svg)](https://mobilisten.io/) [![Mobilisten NPM CD](https://github.com/zoho/SalesIQ-Mobilisten-Cordova/workflows/Mobilisten%20NPM%20CD/badge.svg)](https://github.com/zoho/SalesIQ-Mobilisten-Cordova/actions?query=workflow%3A%22Mobilisten+NPM+CD%22) # SalesIQ Mobilisten SDK - Cordova Plugin diff --git a/package.json b/package.json index 4ef7799..3f702f3 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-zohosalesiq-mobilisten", - "version": "6.0.0", + "version": "7.0.0", "description": "A Cordova plugin for the Zoho SalesIQ Mobilisten SDK", "cordova": { "id": "cordova-zohosalesiq-mobilisten", diff --git a/plugin.xml b/plugin.xml index da46c28..4b9b708 100755 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - ZohoSalesIQ @@ -11,7 +11,7 @@ - + diff --git a/src/android/ZohoSalesIQPlugin.java b/src/android/ZohoSalesIQPlugin.java index 79781d8..5dd0d53 100755 --- a/src/android/ZohoSalesIQPlugin.java +++ b/src/android/ZohoSalesIQPlugin.java @@ -27,7 +27,6 @@ import com.zoho.livechat.android.SIQVisitorLocation; import com.zoho.livechat.android.SalesIQCustomAction; import com.zoho.livechat.android.VisitorChat; -import com.zoho.livechat.android.ZohoLiveChat; import com.zoho.livechat.android.constants.ConversationType; import com.zoho.livechat.android.constants.SalesIQConstants; import com.zoho.livechat.android.exception.InvalidEmailException; @@ -44,6 +43,7 @@ import com.zoho.livechat.android.models.SalesIQArticle; import com.zoho.livechat.android.models.SalesIQArticleCategory; import com.zoho.livechat.android.modules.common.DataModule; +import com.zoho.livechat.android.modules.common.ui.LauncherUtil; 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; @@ -100,6 +100,7 @@ public class ZohoSalesIQPlugin extends CordovaPlugin { private static final String PERFORM_CHATACTION = "PERFORM_CHATACTION"; // No I18N private static final String CUSTOMTRIGGER = "CUSTOMTRIGGER"; // No I18N private static final String BOT_TRIGGER = "BOT_TRIGGER"; // No I18N + private static final String HANDLE_CUSTOM_LAUNCHER_VISIBILITY = "HANDLE_CUSTOM_LAUNCHER_VISIBILITY"; // No I18N private static final String CHAT_QUEUE_POSITION_CHANGED = "CHAT_QUEUE_POSITION_CHANGED"; // No I18N private static final String HANDLE_URL = "HANDLE_URL"; // No I18N @@ -114,10 +115,13 @@ public class ZohoSalesIQPlugin extends CordovaPlugin { private static final int INVALID_FILTER_CODE = 604; private static final String INVALID_FILTER_TYPE = "invalid filter type"; // No I18N - private static final String LAUNCHER_HORIZONTAL_LEFT = "LAUNCHER_HORIZONTAL_LEFT"; - private static final String LAUNCHER_HORIZONTAL_RIGHT = "LAUNCHER_HORIZONTAL_RIGHT"; - private static final String LAUNCHER_VERTICAL_TOP = "LAUNCHER_VERTICAL_TOP"; - private static final String LAUNCHER_VERTICAL_BOTTOM = "LAUNCHER_VERTICAL_BOTTOM"; + private static final String LAUNCHER_HORIZONTAL_LEFT = "LAUNCHER_HORIZONTAL_LEFT"; // No I18N + private static final String LAUNCHER_HORIZONTAL_RIGHT = "LAUNCHER_HORIZONTAL_RIGHT"; // No I18N + private static final String LAUNCHER_VERTICAL_TOP = "LAUNCHER_VERTICAL_TOP"; // No I18N + private static final String LAUNCHER_VERTICAL_BOTTOM = "LAUNCHER_VERTICAL_BOTTOM"; // No I18N + private static final String LAUNCHER_VISIBILITY_MODE_ALWAYS = "LAUNCHER_VISIBILITY_MODE_ALWAYS"; // No I18N + private static final String LAUNCHER_VISIBILITY_MODE_NEVER = "LAUNCHER_VISIBILITY_MODE_NEVER"; // No I18N + private static final String LAUNCHER_VISIBILITY_MODE_WHEN_ACTIVE_CHAT = "LAUNCHER_VISIBILITY_MODE_WHEN_ACTIVE_CHAT"; // No I18N private static final String EVENT_OPEN_URL = "EVENT_OPEN_URL"; // No I18N private static final String EVENT_COMPLETE_CHAT_ACTION = "EVENT_COMPLETE_CHAT_ACTION";// No I18N @@ -357,7 +361,16 @@ public void run() { if (action.equals("setThemeForAndroid")) { this.setThemeForAndroid((String) data.get(0)); } + if (action.equals("dismissUI")) { + this.dismissUI(); + } + if (action.contains("Chat")) { + Chat.handleMethodCalls(action, data, callbackContext); + } + if (action.contains("Launcher")) { + Launcher.handleMethodCalls(action, data, callbackContext); + } if (action.contains("KnowledgeBase")) { KnowledgeBase.handleKnowledgeBaseCalls(action, data, callbackContext); } @@ -366,6 +379,54 @@ public void run() { return false; } + static class Chat { + public static void handleMethodCalls(String action, JSONArray data, CallbackContext callbackContext) { + try { + if (action.equals("showChatFeedbackAfterSkip")) { // No I18N + ZohoSalesIQ.Chat.showFeedbackAfterSkip(LiveChatUtil.getBoolean(data.get(0))); + } else if (action.equals("showChatFeedbackUpTo")) { // No I18N + ZohoSalesIQ.Chat.showFeedback(LiveChatUtil.getInteger(data.get(0))); + } + } catch (JSONException e) { + throw new RuntimeException(e); + } + } + } + + static class Launcher { + + private static ZohoSalesIQ.Launcher.VisibilityMode getVisibilityMode(final String mode) { + ZohoSalesIQ.Launcher.VisibilityMode visibilityMode = ZohoSalesIQ.Launcher.VisibilityMode.NEVER; + switch (mode) { + case LAUNCHER_VISIBILITY_MODE_ALWAYS: + visibilityMode = ZohoSalesIQ.Launcher.VisibilityMode.ALWAYS; + break; + case LAUNCHER_VISIBILITY_MODE_WHEN_ACTIVE_CHAT: + visibilityMode = ZohoSalesIQ.Launcher.VisibilityMode.WHEN_ACTIVE_CHAT; + break; + } + return visibilityMode; + } + + public static void handleMethodCalls(final String action, final JSONArray data, final CallbackContext callbackContext) { + try { + switch (action) { + case "setLauncherVisibilityMode": + ZohoSalesIQ.Launcher.show(getVisibilityMode(LiveChatUtil.getString(data.get(0)))); + break; + case "setVisibilityModeToCustomLauncher": + ZohoSalesIQ.Launcher.setVisibilityModeToCustomLauncher(getVisibilityMode(LiveChatUtil.getString(data.get(0)))); + break; + case "enableLauncherDragToDismiss": + ZohoSalesIQ.Launcher.enableDragToDismiss(LiveChatUtil.getBoolean(data.get(0))); + break; + } + } catch (JSONException e) { + throw new RuntimeException(e); + } + } + } + private void init(final String appKey, final String accessKey, final CallbackContext callbackContext) { final Application context = this.cordova.getActivity().getApplication(); @@ -581,7 +642,7 @@ public void run() { if (ZohoSalesIQ.getApplicationManager().getCurrentActivity() == null) { ZohoSalesIQ.getApplicationManager().setCurrentActivity(activity); } - ZohoSalesIQ.getApplicationManager().refreshChatBubble(); + LauncherUtil.refreshLauncher(); } } }); @@ -864,7 +925,7 @@ private void getDepartments(final CallbackContext departmentCallback) { Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { public void run() { - ZohoLiveChat.Chat.getDepartments(new DepartmentListener() { + ZohoSalesIQ.Chat.getDepartments(new DepartmentListener() { @Override public void onSuccess(ArrayList departmentsList) { if (departmentsList != null) { @@ -926,7 +987,7 @@ public void onFailure(int code, String message) { private void getArticlesWithCategoryID(final String categoryId, final CallbackContext articlesCallback) { - ZohoSalesIQ.KnowledgeBase.getResources(ZohoSalesIQ.ResourceType.Articles, null, categoryId, null, new ResourcesListener() { + ZohoSalesIQ.KnowledgeBase.getResources(ZohoSalesIQ.ResourceType.Articles, null, categoryId, null, false, new ResourcesListener() { @Override public void onSuccess(@NonNull List resources, boolean b) { ArrayList array = new ArrayList<>(); @@ -1164,12 +1225,7 @@ public void onInitComplete() { ZohoSalesIQ.Notification.enablePush(fcmtoken, istestdevice); } if (activity != null && ZohoSalesIQ.getApplicationManager() != null) { - Handler handler = new Handler(Looper.getMainLooper()); - handler.post(new Runnable() { - public void run() { - ZohoSalesIQ.getApplicationManager().refreshChatBubble(); - } - }); + LauncherUtil.refreshLauncher(); } if (callbackContext != null) { callbackContext.success(); @@ -1193,9 +1249,22 @@ public void onInitError() { } void eventEmitter(String event, Object value) { - String pluginName = "ZohoSalesIQ"; // No I18N - cordova.getActivity().runOnUiThread(() -> webView.loadUrl("javascript:" + pluginName + - ".sendEventToJs('" + event + "', " + (value != null ? JSONObject.quote(value.toString()) : null) + ");")); // No I18N + try { + Object result = null; + if (value != null) { + if (value instanceof Boolean) { + result = (boolean) value; + } else { + result = JSONObject.quote(value.toString()); + } + } + String pluginName = "ZohoSalesIQ"; // No I18N + Object finalResult = result; + cordova.getActivity().runOnUiThread(() -> webView.loadUrl("javascript:" + pluginName + + ".sendEventToJs('" + event + "', " + finalResult + ");")); // No I18N + } catch (Exception ignore) { + + } } private Boolean isValidFilterName(String filterName) { @@ -1557,6 +1626,12 @@ public void handleBotTrigger() { eventEmitter(BOT_TRIGGER, null); } + @Override + public void handleCustomLauncherVisibility(boolean visible) { + SalesIQListener.super.handleCustomLauncherVisibility(visible); + eventEmitter(HANDLE_CUSTOM_LAUNCHER_VISIBILITY, visible); + } + @Override public void handleChatOpened(VisitorChat visitorChat) { HashMap visitorMap = getChatMapObject(visitorChat); @@ -1702,13 +1777,7 @@ public void setLauncherIconForAndroid(String resourceName) { } public void refreshLauncher() { - HANDLER.post(() -> { - SalesIQApplicationManager salesIQApplicationManager = - ZohoSalesIQ.getApplicationManager(); - if (salesIQApplicationManager != null && salesIQApplicationManager.canShowBubble(salesIQApplicationManager.getCurrentActivity())) { - salesIQApplicationManager.showChatBubble(salesIQApplicationManager.getCurrentActivity()); - } - }); + LauncherUtil.refreshLauncher(); } public void sendEvent(final String event, final JSONArray objects) { @@ -1823,6 +1892,14 @@ void setThemeForAndroid(final String name) { } } + void dismissUI() { + ZohoSalesIQ.dismissUI(); + } + + void showFeedbackAfterSkip(final boolean enable) { + ZohoSalesIQ.Chat.showFeedbackAfterSkip(enable); + } + void setLoggerEnabled(final boolean value) { ZohoSalesIQ.Logger.setEnabled(value); } @@ -1845,6 +1922,15 @@ static class KnowledgeBase { return resourceType; } + static void isKnowledgeBaseEnabled(final String type, final CallbackContext callbackContext) { + executeIfResourceTypeIsValid(type, callbackContext, () -> callbackContext.success(LiveChatUtil.getString(ZohoSalesIQ.KnowledgeBase.isEnabled(getResourceType(type))))); + } + + static void setKnowledgeBaseRecentlyViewedCount(final int limit) { + ZohoSalesIQ.KnowledgeBase.setRecentlyViewedCount(limit); + } + + static void setVisibility(final String type, final boolean shouldShow) { executeIfResourceTypeIsValid(type, null, () -> ZohoSalesIQ.KnowledgeBase.setVisibility(getResourceType(type), shouldShow)); } @@ -1903,8 +1989,8 @@ public void onFailure(int code, @Nullable String message) { })); } - static void getResources(final String type, final String departmentID, final String parentCategoryID, final int page, final int limit, final String searchKey, final CallbackContext callbackContext) { - executeIfResourceTypeIsValid(type, callbackContext, () -> ZohoSalesIQ.KnowledgeBase.getResources(getResourceType(type), departmentID, parentCategoryID, searchKey, page, limit, new ResourcesListener() { + static void getResources(final String type, final String departmentID, final String parentCategoryID, final int page, final int limit, final String searchKey, final boolean includeChildCategoryResources, final CallbackContext callbackContext) { + executeIfResourceTypeIsValid(type, callbackContext, () -> ZohoSalesIQ.KnowledgeBase.getResources(getResourceType(type), departmentID, parentCategoryID, searchKey, page, limit, includeChildCategoryResources, new ResourcesListener() { @Override public void onSuccess(@NonNull List resources, boolean moreDataAvailable) { JSONObject successJson = new JSONObject(); @@ -1951,9 +2037,14 @@ static void handleKnowledgeBaseCalls(String action, JSONArray data, CallbackCont try { if (action.equals("getKnowledgeBaseResourceDepartments")) { KnowledgeBase.getResourceDepartments(callbackContext); + } else if (action.equals("setKnowledgeBaseRecentlyViewedCount")) { + KnowledgeBase.setKnowledgeBaseRecentlyViewedCount(LiveChatUtil.getInteger(data.get(0))); } else { String type = data.get(0).toString(); switch (action) { + case "isKnowledgeBaseEnabled": + KnowledgeBase.isKnowledgeBaseEnabled(type, callbackContext); + break; case "setKnowledgeBaseVisibility": KnowledgeBase.setVisibility(type, LiveChatUtil.getBoolean(data.get(1))); break; @@ -1970,7 +2061,7 @@ static void handleKnowledgeBaseCalls(String action, JSONArray data, CallbackCont KnowledgeBase.getSingleResource(type, LiveChatUtil.getString(data.get(1)), callbackContext); break; case "getKnowledgeBaseResources": - KnowledgeBase.getResources(type, getStringOrNull(data.get(1)), getStringOrNull(data.get(2)), LiveChatUtil.getInteger(data.get(3)), LiveChatUtil.getInteger(data.get(4)), getStringOrNull(data.get(5)), callbackContext); + KnowledgeBase.getResources(type, getStringOrNull(data.get(1)), getStringOrNull(data.get(2)), LiveChatUtil.getInteger(data.get(3)), LiveChatUtil.getInteger(data.get(4)), getStringOrNull(data.get(5)), false, callbackContext); break; case "getKnowledgeBaseCategories": KnowledgeBase.getCategories(type, getStringOrNull(data.get(1)), getStringOrNull(data.get(2)), callbackContext); diff --git a/src/android/zohosalesIQ.gradle b/src/android/zohosalesIQ.gradle index 3dd074b..e47aa90 100755 --- a/src/android/zohosalesIQ.gradle +++ b/src/android/zohosalesIQ.gradle @@ -5,6 +5,6 @@ repositories { } dependencies { - implementation "com.zoho.salesiq:mobilisten:6.0.2" + implementation "com.zoho.salesiq:mobilisten:7.0.0" implementation 'com.google.code.gson:gson:2.8.6' } diff --git a/src/ios/ZohoSalesIQPlugin.m b/src/ios/ZohoSalesIQPlugin.m index 6ea2a71..41caa41 100755 --- a/src/ios/ZohoSalesIQPlugin.m +++ b/src/ios/ZohoSalesIQPlugin.m @@ -72,6 +72,13 @@ @implementation ZohoSalesIQPlugin NSString *RESOURCE_LIKED = @"RESOURCE_LIKED"; NSString *RESOURCE_DISLIKED = @"RESOURCE_DISLIKED"; +NSString *LAUNCHER_VISIBILITY_MODE_ALWAYS = @"LAUNCHER_VISIBILITY_MODE_ALWAYS"; +NSString *LAUNCHER_VISIBILITY_MODE_NEVER = @"LAUNCHER_VISIBILITY_MODE_NEVER"; +NSString *LAUNCHER_VISIBILITY_MODE_WHEN_ACTIVE_CHAT = @"LAUNCHER_VISIBILITY_MODE_WHEN_ACTIVE_CHAT"; + +NSString *HANDLE_CUSTOM_LAUNCHER_VISIBILITY = @"HANDLE_CUSTOM_LAUNCHER_VISIBILITY"; + + bool handleURI = YES; @@ -213,6 +220,26 @@ - (void)setLanguage:(CDVInvokedUrlCommand*)command{ [[ZohoSalesIQ Chat] setLanguage:LanguageArmenian]; }else if([language_code isEqualToString:@"fa"]){ [[ZohoSalesIQ Chat] setLanguage:LanguagePersian]; + }else if([language_code isEqualToString:@"ta"]){ + [[ZohoSalesIQ Chat] setLanguage:LanguageTamil]; + }else if([language_code isEqualToString:@"kn"]){ + [[ZohoSalesIQ Chat] setLanguage:LanguageKannada]; + }else if([language_code isEqualToString:@"bn"]){ + [[ZohoSalesIQ Chat] setLanguage:LanguageBengali]; + }else if([language_code isEqualToString:@"hi"]){ + [[ZohoSalesIQ Chat] setLanguage:LanguageHindi]; + }else if([language_code isEqualToString:@"gu"]){ + [[ZohoSalesIQ Chat] setLanguage:LanguageGujarati]; + }else if([language_code isEqualToString:@"mr"]){ + [[ZohoSalesIQ Chat] setLanguage:LanguageMarathi]; + }else if([language_code isEqualToString:@"te"]){ + [[ZohoSalesIQ Chat] setLanguage:LanguageTelugu]; + }else if([language_code isEqualToString:@"pa"]){ + [[ZohoSalesIQ Chat] setLanguage:LanguagePunjabi]; + }else if([language_code isEqualToString:@"or"]){ + [[ZohoSalesIQ Chat] setLanguage:LanguageOriya]; + }else if([language_code isEqualToString:@"ml"]){ + [[ZohoSalesIQ Chat] setLanguage:LanguageMalayalam]; }else{ [[ZohoSalesIQ Chat] setLanguage:LanguageEnglish]; } @@ -895,7 +922,27 @@ - (void)openArticle:(CDVInvokedUrlCommand*)command{ } } +- (void)dismissUI:(CDVInvokedUrlCommand*)command{ + [ZohoSalesIQ dismissUI]; +} + + //MARK:- KNOWLEGEBASE APIs +- (void)isKnowledgeBaseEnabled: (CDVInvokedUrlCommand*)command { + NSString *type = [command.arguments objectAtIndex:0]; + if ([type isEqualToString: RESOURCE_ARTICLES]) { + BOOL knowledgebaseEnabled = [[ZohoSalesIQ KnowledgeBase] isEnabled: SIQResourceTypeArticles]; + CDVPluginResult* pluginResult = nil; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:knowledgebaseEnabled]; + [[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId]; + } +} + +- (void)setKnowledgeBaseRecentlyViewedCount:(CDVInvokedUrlCommand*)command{ + NSInteger limit = [[command.arguments objectAtIndex:0] integerValue]; + [[ZohoSalesIQ KnowledgeBase] setRecentShowLimit:limit]; +} + - (void)setKnowledgeBaseVisibility:(CDVInvokedUrlCommand*)command{ NSString *type = [command.arguments objectAtIndex:0]; BOOL enable = [[command.arguments objectAtIndex:1] boolValue]; @@ -1046,6 +1093,45 @@ - (void)getKnowledgeBaseCategories:(CDVInvokedUrlCommand*)command { } } +//MARK:- Feedback APIs +- (void)showChatFeedbackAfterSkip:(CDVInvokedUrlCommand*)command{ + BOOL skip = [[command.arguments objectAtIndex:0] boolValue]; + [[ZohoSalesIQ Chat] showFeedbackAfterSkip:skip]; +} + +- (void)showChatFeedbackUpTo:(CDVInvokedUrlCommand*)command{ + NSInteger duration = [[command.arguments objectAtIndex:0] integerValue]; + [[ZohoSalesIQ Chat] showFeedbackWithUptoDuration: duration]; +} + +//MARK:- Launcher APIs +- (void)setLauncherVisibilityMode:(CDVInvokedUrlCommand*)command{ + NSString *mode = [command.arguments objectAtIndex:0]; + if ([mode isEqualToString: LAUNCHER_VISIBILITY_MODE_ALWAYS]) { + [[ZohoSalesIQ Launcher] show:VisibilityModeAlways]; + } else if ([mode isEqualToString: LAUNCHER_VISIBILITY_MODE_NEVER]) { + [[ZohoSalesIQ Launcher] show:VisibilityModeNever]; + } else if ([mode isEqualToString: LAUNCHER_VISIBILITY_MODE_WHEN_ACTIVE_CHAT]) { + [[ZohoSalesIQ Launcher] show:VisibilityModeWhenActiveChat]; + } +} + +- (void)setVisibilityModeToCustomLauncher:(CDVInvokedUrlCommand*)command{ + NSString *mode = [command.arguments objectAtIndex:0]; + if ([mode isEqualToString: LAUNCHER_VISIBILITY_MODE_ALWAYS]) { + [[ZohoSalesIQ Launcher] setVisibilityModeToCustomLauncher:VisibilityModeAlways]; + } else if ([mode isEqualToString: LAUNCHER_VISIBILITY_MODE_NEVER]) { + [[ZohoSalesIQ Launcher] setVisibilityModeToCustomLauncher:VisibilityModeNever]; + } else if ([mode isEqualToString: LAUNCHER_VISIBILITY_MODE_WHEN_ACTIVE_CHAT]) { + [[ZohoSalesIQ Launcher] setVisibilityModeToCustomLauncher:VisibilityModeWhenActiveChat]; + } +} + +- (void)enableLauncherDragToDismiss:(CDVInvokedUrlCommand*)command{ + BOOL enable = [[command.arguments objectAtIndex:0] boolValue]; + [[ZohoSalesIQ Launcher] enableDragToDismiss:enable]; +} + //MARK:- INTERNAL HELPER METHODS @@ -1086,9 +1172,11 @@ - (void)sendEvent:(NSString*)name body:(id)body { body = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:body options:0 error:NULL] encoding:NSUTF8StringEncoding]; } NSString *script = @""; - if([body isKindOfClass:[NSNumber class]]){ + if ([name isEqualToString: HANDLE_CUSTOM_LAUNCHER_VISIBILITY]) { + script = [NSString stringWithFormat:@"%@.sendEventToJs(`%@`, %s)", serviceName, name,[body boolValue] ? "true" : "false"]; + } else if([body isKindOfClass:[NSNumber class]]){ script = [NSString stringWithFormat:@"%@.sendEventToJs(`%@`, %@)", serviceName, name, body]; - }else{ + } else{ if([body isKindOfClass:[NSString class]]){ NSString *jsonString = (NSString*)body; jsonString = [jsonString stringByReplacingOccurrencesOfString:@"`" withString:@"\""]; @@ -1825,4 +1913,9 @@ - (void)handleResourceDisliked:(enum SIQResourceType)type resource:(SIQKnowledge [self sendEvent:RESOURCE_DISLIKED body: resourceInformation]; } +- (void)handleCustomLauncherVisibility:(BOOL)visible { + NSNumber *visibleValue = [NSNumber numberWithBool:visible]; + [self sendEvent:HANDLE_CUSTOM_LAUNCHER_VISIBILITY body: visibleValue]; +} + @end diff --git a/www/ZohoSalesIQ.js b/www/ZohoSalesIQ.js index 84e6b39..24d8ae2 100755 --- a/www/ZohoSalesIQ.js +++ b/www/ZohoSalesIQ.js @@ -30,6 +30,7 @@ exports.EVENT = { RESOURCE_CLOSED: "RESOURCE_CLOSED", // No I18N RESOURCE_LIKED: "RESOURCE_LIKED", // No I18N RESOURCE_DISLIKED: "RESOURCE_DISLIKED", // No I18N + HANDLE_CUSTOM_LAUNCHER_VISIBILITY: "HANDLE_CUSTOM_LAUNCHER_VISIBILITY",// No I18N }; exports.Resource = { @@ -40,13 +41,28 @@ exports.Resource = { exports.Launcher = { STATIC_MODE: 1, FLOATING_MODE: 2, - HORIZONTAL_LEFT: "LAUNCHER_HORIZONTAL_LEFT", - HORIZONTAL_RIGHT: "LAUNCHER_HORIZONTAL_RIGHT", - VERTICAL_TOP: "LAUNCHER_VERTICAL_TOP", - VERTICAL_BOTTOM: "LAUNCHER_VERTICAL_BOTTOM", + HORIZONTAL_LEFT: "LAUNCHER_HORIZONTAL_LEFT", // No I18N + HORIZONTAL_RIGHT: "LAUNCHER_HORIZONTAL_RIGHT", // No I18N + VERTICAL_TOP: "LAUNCHER_VERTICAL_TOP", // No I18N + VERTICAL_BOTTOM: "LAUNCHER_VERTICAL_BOTTOM", // No I18N + + VisibilityMode: { + ALWAYS: "LAUNCHER_VISIBILITY_MODE_ALWAYS", // No I18N + NEVER: "LAUNCHER_VISIBILITY_MODE_NEVER", // No I18N + WHEN_ACTIVE_CHAT: "LAUNCHER_VISIBILITY_MODE_WHEN_ACTIVE_CHAT", // No I18N + }, setIconForAndroid: function (resourceName) { exec(null, null, serviceName, 'setLauncherIconForAndroid', [resourceName]); // No I18N + }, + show: function (visibilityMode) { + exec(null, null, serviceName, 'setLauncherVisibilityMode', [visibilityMode]); // No I18N + }, + setVisibilityModeToCustomLauncher: function (visibilityMode) { + exec(null, null, serviceName, 'setVisibilityModeToCustomLauncher', [visibilityMode]); // No I18N + }, + enableDragToDismiss: function (enable) { + exec(null, null, serviceName, 'enableLauncherDragToDismiss', [enable]); // No I18N } } @@ -340,7 +356,7 @@ exports.sendEventToJs = function (name, body) { if (body) { listener_list[i](parseResult(body)); } else { - listener_list[i](); + listener_list[i](body); } } } @@ -359,9 +375,19 @@ exports.printDebugLogsForAndroid = function (value) { exec(null, null, serviceName, 'printDebugLogsForAndroid', [value]); // No I18N } +exports.dismissUI = function () { + exec(null, null, serviceName, 'dismissUI', []); // No I18N +}, + exports.Chat = { shouldOpenUrl: function (value) { exec(null, null, serviceName, 'shouldOpenUrl', [value]); // No I18N + }, + showFeedbackAfterSkip: function (enable) { + exec(null, null, serviceName, 'showChatFeedbackAfterSkip', [enable]); // No I18N + }, + showFeedback(upToDuration) { + exec(null, null, serviceName, 'showChatFeedbackUpTo', [upToDuration]); // No I18N } } @@ -380,7 +406,6 @@ exports.Notification = { } } - exports.Logger = { INFO: "INFO", @@ -405,9 +430,9 @@ exports.Logger = { } exports.KnowledgeBase = { -// isEnabled: function (type, callback) { -// RNZohoSalesIQ.isKnowledgeBaseEnabled(type, callback); -// }, + isEnabled: function (type, success, error) { + exec(success, error, serviceName, 'isKnowledgeBaseEnabled', [type]); // No I18N + }, setVisibility: function (type, shouldShow) { exec(null, null, serviceName, 'setKnowledgeBaseVisibility', [type, shouldShow]); // No I18N }, @@ -417,9 +442,9 @@ exports.KnowledgeBase = { combineDepartments: function (type, merge) { exec(null, null, serviceName, 'combineKnowledgeBaseDepartments', [type, merge]); // No I18N }, - // setRecentShowLimit: function (value) { - // exec(null, null, serviceName, 'setKnowledgeBaseRecentShowLimit', [value]); // No I18N - // }, + setRecentlyViewedCount: function (limit) { + exec(null, null, serviceName, 'setKnowledgeBaseRecentlyViewedCount', [limit]); // No I18N + }, getResourceDepartments: function (success, error) { exec(success, error, serviceName, 'getKnowledgeBaseResourceDepartments', []); // No I18N },