From 21491314b46c43dc12a4514e5c87e23c00655ecd Mon Sep 17 00:00:00 2001 From: Kasiviswanath Senthilkumar Date: Wed, 11 Sep 2024 13:21:17 +0530 Subject: [PATCH] Release v8.1.0 Release v8.1.0 --- README.md | 2 +- package.json | 2 +- plugin.xml | 5 +- src/android/ZohoSalesIQPlugin.java | 83 ++++++ src/android/zohosalesIQ.gradle | 2 +- src/ios/ZohoSalesIQPlugin.m | 204 ++++++++++++- www/SIQTheme.js | 460 +++++++++++++++++++++++++++++ www/ZohoSalesIQ.js | 63 ++-- 8 files changed, 794 insertions(+), 27 deletions(-) create mode 100755 www/SIQTheme.js diff --git a/README.md b/README.md index 70eaee1..a280eaf 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-8.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-8.1.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 d4e00c2..b6ee357 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-zohosalesiq-mobilisten", - "version": "8.0.0", + "version": "8.1.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 e993a57..69436bc 100755 --- a/plugin.xml +++ b/plugin.xml @@ -5,13 +5,16 @@ + + + - + diff --git a/src/android/ZohoSalesIQPlugin.java b/src/android/ZohoSalesIQPlugin.java index 8998072..17da96a 100755 --- a/src/android/ZohoSalesIQPlugin.java +++ b/src/android/ZohoSalesIQPlugin.java @@ -44,6 +44,7 @@ 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.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; @@ -155,6 +156,9 @@ public boolean execute(String action, JSONArray data, CallbackContext callbackCo if (action.equalsIgnoreCase("init")) { this.init(data.get(0).toString(), data.get(1).toString(), callbackContext); } + if (action.equalsIgnoreCase("present")) { + this.present(getStringOrNull(data.get(0)), getStringOrNull(data.get(1)), callbackContext); + } if (action.equals("enableScreenshotOption")) { this.enableScreenshotOption(); } @@ -388,6 +392,47 @@ public static void handleMethodCalls(String action, JSONArray data, CallbackCont ZohoSalesIQ.Chat.showFeedback(LiveChatUtil.getInteger(data.get(0))); } else if (action.contains("isChatEnabled")) { Chat.isChatEnabled(callbackContext); + } else if (action.equals("setChatWaitingTime")) { + ZohoSalesIQ.Chat.setWaitingTime(LiveChatUtil.getInteger(data.get(0))); + } else if (action.equals("startNewChat")) { + ZohoSalesIQ.Chat.start(LiveChatUtil.getString(data.get(0)), getStringOrNull(data.get(1)), getStringOrNull(data.get(2)), chatResult -> { + if (chatResult.isSuccess()) { + callbackContext.success(getAsJSONObject(chatResult.getData())); + } else { + SalesIQError error = chatResult.getError(); + if (error != null) { + callbackContext.error(getErrorJson(error.getCode(), error.getMessage())); + } else { + callbackContext.error("Unknown error occurred while starting a new chat."); //No I18N + } + } + }); + } else if (action.equals("startNewChatWithTrigger")) { + ZohoSalesIQ.Chat.startWithTrigger(getStringOrNull(data.get(0)), getStringOrNull(data.get(1)), chatResult -> { + if (chatResult.isSuccess()) { + callbackContext.success(getAsJSONObject(chatResult.getData())); + } else { + SalesIQError error = chatResult.getError(); + if (error != null) { + callbackContext.error(getErrorJson(error.getCode(), error.getMessage())); + } else { + callbackContext.error("Unknown error occurred while starting a new chat with trigger."); //No I18N + } + } + }); + } else if (action.equals("getChat")) { + ZohoSalesIQ.Chat.get(LiveChatUtil.getString(data.get(0)), chatResult -> { + if (chatResult.isSuccess()) { + callbackContext.success(getAsJSONObject(chatResult.getData())); + } else { + SalesIQError error = chatResult.getError(); + if (error != null) { + callbackContext.error(getErrorJson(error.getCode(), error.getMessage())); + } else { + callbackContext.error("Unknown error occurred while getting the chat."); //No I18N + } + } + }); } } catch (JSONException e) { throw new RuntimeException(e); @@ -433,6 +478,9 @@ public static void handleMethodCalls(final String action, final JSONArray data, case "enableLauncherDragToDismiss": ZohoSalesIQ.Launcher.enableDragToDismiss(LiveChatUtil.getBoolean(data.get(0))); break; + case "setLauncherMinimumPressDuration": + ZohoSalesIQ.Launcher.setMinimumPressDuration(LiveChatUtil.getInteger(data.get(0))); + break; } } catch (JSONException e) { throw new RuntimeException(e); @@ -455,6 +503,31 @@ public void run() { }); } + private static void present(@Nullable final String tab, @Nullable final String id, final CallbackContext callbackContext) { + ZohoSalesIQ.present(getTab(tab), id, presentResult -> { + if (presentResult.isSuccess()) { + callbackContext.success(1); + } else { + SalesIQError error = presentResult.getError(); + if (error != null) { + callbackContext.error(getErrorJson(error.getCode(), error.getMessage())); + } else { + callbackContext.error("Unknown error occurred while presenting the tab."); //No I18N + } + } + }); + } + + private static @Nullable ZohoSalesIQ.Tab getTab(@Nullable String tab) { + ZohoSalesIQ.Tab tabType = 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; + } + private void enableScreenshotOption() { Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @@ -2179,6 +2252,16 @@ static JSONObject getErrorJson(int code, String message) { return errorMap; } + private static @Nullable String getStringOrNull(Object object) { + String value; + if (object == null || object == JSONObject.NULL) { + value = null; + } else { + value = (String) object; + } + return value; + } + // void clearLogsForiOS() {} // void setLoggerPathForiOS(final String value) {} diff --git a/src/android/zohosalesIQ.gradle b/src/android/zohosalesIQ.gradle index e47aa90..49e0c36 100755 --- a/src/android/zohosalesIQ.gradle +++ b/src/android/zohosalesIQ.gradle @@ -5,6 +5,6 @@ repositories { } dependencies { - implementation "com.zoho.salesiq:mobilisten:7.0.0" + api "com.zoho.salesiq:mobilisten:8.0.5" implementation 'com.google.code.gson:gson:2.8.6' } diff --git a/src/ios/ZohoSalesIQPlugin.m b/src/ios/ZohoSalesIQPlugin.m index 191f752..7ef21d0 100755 --- a/src/ios/ZohoSalesIQPlugin.m +++ b/src/ios/ZohoSalesIQPlugin.m @@ -81,6 +81,9 @@ @implementation ZohoSalesIQPlugin NSString *ACTION_SOURCE_APP = @"ACTION_SOURCE_APP"; NSString *ACTION_SOURCE_SDK = @"ACTION_SOURCE_SDK"; NSString *NOTIFICATION_CLICKED = @"NOTIFICATION_CLICKED"; +NSString *PAYLOAD_CHAT = @"chat"; +NSString *PAYLOAD_END_CHAT = @"endChatDetails"; +NSString *PAYLOAD_VISITOR_HISTORY = @"visitorHistory"; bool handleURI = YES; @@ -306,6 +309,12 @@ - (void)setThemeColorforiOS:(CDVInvokedUrlCommand*)command{ } } +- (void)setThemeForiOS:(CDVInvokedUrlCommand*)command { + NSDictionary *colors = [command.arguments objectAtIndex:0]; + SIQTheme *theme = [[SIQTheme alloc] initWithColors:colors]; + [[ZohoSalesIQ Theme] setThemeWithTheme:theme]; +} + - (void)setThemeColorforAndroid:(CDVInvokedUrlCommand*)command{ // No Implementation } @@ -778,6 +787,150 @@ - (void)startChat:(CDVInvokedUrlCommand*)command{ } } +- (void)present:(CDVInvokedUrlCommand*)command { + NSString *tab = nil; + NSString *referenceId = nil; + + if (command.arguments.count > 0) { + id arg = [command.arguments objectAtIndex:0]; + if (arg != [NSNull null]) { + tab = (NSString *)arg; + } + } + + if (command.arguments.count > 1) { + id arg = [command.arguments objectAtIndex:1]; + if (arg != [NSNull null]) { + referenceId = (NSString *)arg; + } + } + + NSNumber *tabNumber = nil; + if (tab) { + if ([tab isEqual:CONVERSATIONS]) { + tabNumber = [NSNumber numberWithInteger:0]; + } else if ([tab isEqual:FAQ] || [tab isEqual:KNOWLEDGEBASE]) { + tabNumber = [NSNumber numberWithInteger:1]; + } + } + + + [ZohoSalesIQ presentWithTabBarItem:tabNumber referenceID:referenceId shouldShowListView:YES completion:^(id _Nullable error, BOOL success) { + CDVPluginResult* pluginResult = nil; + if (error != nil) { + NSMutableDictionary *errorDictionary = [self getSIQErrorObject:error]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:errorDictionary]; + [[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId]; + } else { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES]; + [[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId]; + } + }]; +} + +- (void)startNewChat:(CDVInvokedUrlCommand*)command { + NSString *question = [command.arguments objectAtIndex:0]; + NSString *customChatId = nil; + NSString *departmentId = nil; + + if (command.arguments.count > 1) { + id arg = [command.arguments objectAtIndex:1]; + if (arg != [NSNull null]) { + customChatId = (NSString *)arg; + } + } + + if (command.arguments.count > 2) { + id arg = [command.arguments objectAtIndex:2]; + if (arg != [NSNull null]) { + departmentId = (NSString *)arg; + } + } + + [[ZohoSalesIQ Chat] startWithQuestion:question chatID:customChatId department:departmentId completion:^(id _Nullable error, SIQVisitorChat * _Nullable chat) { + CDVPluginResult* pluginResult = nil; + if(error != nil){ + NSMutableDictionary *errorDictionary = [self getSIQErrorObject:error]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:errorDictionary]; + [[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId]; + }else{ + NSMutableDictionary *chatDict = [NSMutableDictionary dictionary]; + chatDict = [self getChatObject:chat]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:chatDict]; + [[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId]; + } + }]; +} + +- (void)startNewChatWithTrigger:(CDVInvokedUrlCommand*)command { + NSString *customChatId = nil; + NSString *departmentId = nil; + + if (command.arguments.count > 0) { + id arg = [command.arguments objectAtIndex:0]; + if (arg != [NSNull null]) { + customChatId = (NSString *)arg; + } + } + + if (command.arguments.count > 1) { + id arg = [command.arguments objectAtIndex:1]; + if (arg != [NSNull null]) { + departmentId = (NSString *)arg; + } + } + + [[ZohoSalesIQ Chat] startWithTriggerWithChatID:customChatId department:departmentId completion:^(id _Nullable error, SIQVisitorChat * _Nullable chat) { + CDVPluginResult* pluginResult = nil; + if(error != nil){ + NSMutableDictionary *errorDictionary = [self getSIQErrorObject:error]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:errorDictionary]; + [[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId]; + }else{ + NSMutableDictionary *chatDict = [NSMutableDictionary dictionary]; + chatDict = [self getChatObject:chat]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:chatDict]; + [[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId]; + } + }]; +} + +- (void)setChatWaitingTime:(CDVInvokedUrlCommand*)command { + NSInteger time = [[command.arguments objectAtIndex:0] integerValue]; + [[ZohoSalesIQ Chat] setWaitingTimeWithUpTo:time]; +} + +- (void)getChat:(CDVInvokedUrlCommand*)command { + NSString *chatId = [command.arguments objectAtIndex:0]; + [[ZohoSalesIQ Chat] getWithChatID:chatId completion:^(id _Nullable error, SIQVisitorChat * _Nullable chat) { + CDVPluginResult* pluginResult = nil; + if(error != nil){ + NSMutableDictionary *errorDictionary = [self getSIQErrorObject:error]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:errorDictionary]; + [[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId]; + }else{ + NSMutableDictionary *chatDict = [NSMutableDictionary dictionary]; + chatDict = [self getChatObject:chat]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:chatDict]; + [[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId]; + } + }]; +} + +- (void)openChat:(CDVInvokedUrlCommand*)command { + NSDictionary *payload = [command.arguments objectAtIndex:0]; + NSString *type = payload[@"type"]; + NSDictionary *payloadData = payload[@"payload"]; + + if ([type isEqualToString: PAYLOAD_CHAT]) { + SalesIQChatNotificationPayload *chatObject = [[SalesIQChatNotificationPayload alloc] initWithDictionary:payloadData]; + [[ZohoSalesIQ Chat] openWith:chatObject]; + } else if ([type isEqualToString: PAYLOAD_END_CHAT]) { + SalesIQEndChatNotificationPayload *endChatObject = [[SalesIQEndChatNotificationPayload alloc] initWithDictionary:payloadData]; + [[ZohoSalesIQ Chat] openWith:endChatObject]; + } +} + - (void)registerVisitor:(CDVInvokedUrlCommand*)command{ NSString *visitorID = [command.arguments objectAtIndex:0]; if(visitorID!=nil){ @@ -936,6 +1089,18 @@ - (void)hideQueueTime:(CDVInvokedUrlCommand*)command { [[ZohoSalesIQ Chat] hideQueueTime:hide]; } +- (void)setLauncherMinimumPressDuration:(CDVInvokedUrlCommand*)command { + NSInteger duration = [[command.arguments objectAtIndex:0] integerValue]; + if (duration < 0) { + return; + } + CGFloat seconds = (CGFloat)duration / 1000.0; + [[ZohoSalesIQ Launcher] minimumPressDuration:seconds]; +} + +- (void)refreshLauncher:(CDVInvokedUrlCommand*)command { + [ZohoSalesIQ refreshLauncher]; +} - (void)registerLocalizationFile:(CDVInvokedUrlCommand*)command { NSString *fileName = [command.arguments objectAtIndex:0]; @@ -973,15 +1138,15 @@ - (void)getNotificationPayload:(CDVInvokedUrlCommand*)command { if (completionObject != nil) { if ([completionObject isKindOfClass:[SalesIQChatNotificationPayload class]]) { SalesIQChatNotificationPayload *chatPayload = (SalesIQChatNotificationPayload *)completionObject; - resultMap[@"type"] = @"chat"; + resultMap[@"type"] = PAYLOAD_CHAT; resultMap[@"payload"] = [chatPayload toDictionary]; } else if ([completionObject isKindOfClass:[SalesIQEndChatNotificationPayload class]]) { SalesIQEndChatNotificationPayload *endChatPayload = (SalesIQEndChatNotificationPayload *)completionObject; - resultMap[@"type"] = @"endChatDetails"; + resultMap[@"type"] = PAYLOAD_END_CHAT; resultMap[@"payload"] = [endChatPayload toDictionary]; } else if ([completionObject isKindOfClass:[SalesIQVisitorHistoryNotificationPayload class]]) { SalesIQVisitorHistoryNotificationPayload *visitorHistoryPayload = (SalesIQVisitorHistoryNotificationPayload *)completionObject; - resultMap[@"type"] = @"visitorHistory"; + resultMap[@"type"] = PAYLOAD_VISITOR_HISTORY; resultMap[@"payload"] = [visitorHistoryPayload toDictionary]; } pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resultMap]; @@ -1853,6 +2018,28 @@ - (NSMutableArray *)getDepartmentList: (NSArray *) departments return departmentsArray; } +- (NSMutableDictionary *)getNotificationActionPayload:(id)payload { + NSMutableDictionary *resultMap = [NSMutableDictionary dictionary]; + if (payload != nil) { + if ([payload isKindOfClass:[SalesIQChatNotificationPayload class]]) { + SalesIQChatNotificationPayload *chatPayload = (SalesIQChatNotificationPayload *)payload; + resultMap[@"type"] = @"chat"; + resultMap[@"payload"] = [chatPayload toDictionary]; + } else if ([payload isKindOfClass:[SalesIQEndChatNotificationPayload class]]) { + SalesIQEndChatNotificationPayload *endChatPayload = (SalesIQEndChatNotificationPayload *)payload; + resultMap[@"type"] = @"endChatDetails"; + resultMap[@"payload"] = [endChatPayload toDictionary]; + } else if ([payload isKindOfClass:[SalesIQVisitorHistoryNotificationPayload class]]) { + SalesIQVisitorHistoryNotificationPayload *visitorHistoryPayload = (SalesIQVisitorHistoryNotificationPayload *)payload; + resultMap[@"type"] = @"visitorHistory"; + resultMap[@"payload"] = [visitorHistoryPayload toDictionary]; + } + } else { + NSLog(@"payload object is nil"); + } + return resultMap; +} + - (void)agentsOffline { @@ -1997,15 +2184,15 @@ - (void)handleNotificationActionWithPayload:(NSDictionary *)paylo if (completionObject != nil) { if ([completionObject isKindOfClass:[SalesIQChatNotificationPayload class]]) { SalesIQChatNotificationPayload *chatPayload = (SalesIQChatNotificationPayload *)completionObject; - resultMap[@"type"] = @"chat"; + resultMap[@"type"] = PAYLOAD_CHAT; resultMap[@"payload"] = [chatPayload toDictionary]; } else if ([completionObject isKindOfClass:[SalesIQEndChatNotificationPayload class]]) { SalesIQEndChatNotificationPayload *endChatPayload = (SalesIQEndChatNotificationPayload *)completionObject; - resultMap[@"type"] = @"endChatDetails"; + resultMap[@"type"] = PAYLOAD_END_CHAT; resultMap[@"payload"] = [endChatPayload toDictionary]; } else if ([completionObject isKindOfClass:[SalesIQVisitorHistoryNotificationPayload class]]) { SalesIQVisitorHistoryNotificationPayload *visitorHistoryPayload = (SalesIQVisitorHistoryNotificationPayload *)completionObject; - resultMap[@"type"] = @"visitorHistory"; + resultMap[@"type"] = PAYLOAD_VISITOR_HISTORY; resultMap[@"payload"] = [visitorHistoryPayload toDictionary]; } } else { @@ -2015,4 +2202,9 @@ - (void)handleNotificationActionWithPayload:(NSDictionary *)paylo }]; } +- (void)handleNotificationAction:(SalesIQNotificationPayload *)payload { + NSMutableDictionary *resultMap = [self getNotificationActionPayload:payload]; + [self sendEvent:NOTIFICATION_CLICKED body: resultMap]; +} + @end diff --git a/www/SIQTheme.js b/www/SIQTheme.js new file mode 100755 index 0000000..4b5c6c4 --- /dev/null +++ b/www/SIQTheme.js @@ -0,0 +1,460 @@ +class SIQArticleMessageTheme { + constructor() { + this.cardTitleColor = null; + this.articleTitleColor = null; + this.authorTextColor = null; + this.backgroundColor = null; + } +} + +class SIQArticleTheme { + constructor() { + this.Toolbar = new SIQFAQBottomBarTheme(); + } +} + +class SIQAttachmentSheetTheme { + constructor() { + this.backgroundColor = null; + this.overlayColor = null; + this.tintColor = null; + this.separatorColor = null; + } +} + +class SIQAudioPlayerTheme { + constructor() { + this.thumbColor = null; + this.playButtonBackgroundColor = null; + this.incomingTrackColor = null; + this.outgoingTrackColor = null; + this.incomingButtonIconColor = null; + this.outgoingButtonIconColor = null; + this.outgoingDurationTextColor = null; + this.incomingDurationTextColor = null; + } +} + +class SIQBannerColorTheme { + constructor() { + this.backgroundColor = null; + this.textColor = null; + } +} + +class SIQBannerTheme { + constructor() { + this.successTheme = new SIQBannerColorTheme(); + this.infoTheme = new SIQBannerColorTheme(); + this.failureTheme = new SIQBannerColorTheme(); + } +} + +class SIQButtonTheme { + constructor() { + this.selectedColor = null; + this.normalColor = null; + } +} + +class SIQChatFormTheme { + constructor() { + this.backgroundColor = null; + this.textFieldBackgroundColor = null; + this.textFieldTextColor = null; + this.textFieldTintColor = null; + this.textFieldPlaceholderColor = null; + this.textFieldTitleColor = null; + this.textFieldRequiredIndicatorColor = null; + this.errorColor = null; + this.submitButtonBackgroundColor = null; + this.submitButtonTextColor = null; + this.campaignOptInTextColor = null; + this.checkboxCheckedColor = null; + this.checkboxUncheckedColor = null; + } +} + +class SIQChatInputTheme { + constructor() { + this.backgroundColor = null; + this.audioRecordHintBackgroundColor = null; + this.audioRecordHintTextColor = null; + this.textFieldBorderColor = null; + this.textFieldTintColor = null; + this.textFieldBackgroundColor = null; + this.textFieldPlaceholderColor = null; + this.textFieldTextColor = null; + this.attachmentButtonBackgroundColor = null; + this.recordButtonBackgroundColor = null; + this.recordSoundPulseBackgroundColor = null; + this.sendButtonBackgroundColor = null; + this.buttonDisabledBackgroundColor = null; + this.recordTimerBackgroundColor = null; + this.recordTimerTextColor = null; + this.recordTimerIndicatorColor = null; + this.recordSlideTextColor = null; + this.recordSlideIconColor = null; + this.recordCancelTextColor = null; + this.moreIconColor = null; + this.sendIconColor = null; + this.recordIconColor = null; + this.Reply = new SIQReplyViewTheme(); + this.Edit = new SIQReplyViewTheme(); + } +} + +class SIQChatScrollButtonTheme { + constructor() { + this.iconColor = null; + this.backgroundColor = null; + this.UnreadBadge = new SIQLauncherUnreadBadgeTheme(); + } +} + +class SIQChatWindowTheme { + constructor() { + this.backgroundColor = null; + this.Message = new SIQMessageTheme(); + this.HandOffBanner = new SIQHandOffBannerTheme(); + this.Banner = new SIQBannerTheme(); + this.QueueBanner = new SIQQueueBannerTheme(); + this.Input = new SIQChatInputTheme(); + this.AttachmentsSheet = new SIQAttachmentSheetTheme(); + this.ScrollButton = new SIQChatScrollButtonTheme(); + this.EmailTranscript = new SIQEmailTranscriptTheme(); + this.DebugLog = new SIQLogViewTheme(); + } +} + +class SIQConversationListItemTheme { + constructor() { + this.backgroundColor = null; + this.timerTextColor = null; + this.timerIconColor = null; + this.titleTextColor = null; + this.subtitleTextColor = null; + this.timeTextColor = null; + this.openBadgeBackgroundColor = null; + this.openBadgeBorderColor = null; + this.openBadgeTextColor = null; + this.UnreadBadge = new SIQLauncherUnreadBadgeTheme(); + } +} + +class SIQConversationTheme { + constructor() { + this.backgroundColor = null; + this.ListItem = new SIQConversationListItemTheme(); + } +} + +class SIQEmailTranscriptTheme { + constructor() { + this.textFieldTintColor = null; + } +} + +class SIQEmptyViewTheme { + constructor() { + this.backgroundColor = null; + this.chatButtonBackgroundColor = null; + this.chatButtonTitleColor = null; + this.textColor = null; + } +} + +class SIQFAQBottomBarTheme { + constructor() { + this.backgroundColor = null; + this.LikeButton = new SIQButtonTheme(); + this.DislikeButton = new SIQButtonTheme(); + } +} + +class SIQFAQListItemTheme { + constructor() { + this.backgroundColor = null; + this.titleTextColor = null; + this.subtitleTextColor = null; + this.subtitlePartitionColor = null; + this.likePendingColor = null; + this.likedColor = null; + this.separatorColor = null; + } +} + +class SIQFAQTheme { + constructor() { + this.headerTextColor = null; + this.ListItem = new SIQFAQListItemTheme(); + this.Article = new SIQArticleTheme(); + } +} + +class SIQFeedbackTheme { + constructor() { + this.backgroundColor = null; + this.primaryTextColor = null; + this.secondaryTextColor = null; + this.skipButtonTextColor = null; + this.submitButtonTextColor = null; + this.submitButtonBackgroundColor = null; + this.feedbackTextFieldTintColor = null; + this.feedbackPlaceholderTextColor = null; + } +} + +class SIQFileMessageTheme { + constructor() { + this.incomingTitleColor = null; + this.incomingSubTitleColor = null; + this.outgoingTitleColor = null; + this.outgoingSubTitleColor = null; + this.incomingFileViewBackgroundColor = null; + this.outgoingFileViewBackgroundColor = null; + this.incomingCommentBackgoundColor = null; + this.outgoingCommentBackgoundColor = null; + } +} + +class SIQHandOffBannerTheme { + constructor() { + this.backgroundColor = null; + this.textColor = null; + this.buttonTitleColor = null; + } +} + +class SIQInAppNotificationTheme { + constructor() { + this.titleColor = null; + this.subtitleColor = null; + this.backgroundColor = null; + this.imageBackgroundColor = null; + this.cornerRadius = null; // Int + this.imageCornerRadius = null; // Int + } +} + +class SIQInfoMessageTheme { + constructor() { + this.textColor = null; + this.lineColor = null; + } +} + +class SIQInputCardTheme { + constructor() { + this.titleColor = null; + this.textFieldTextColor = null; + this.textFieldBackgroundColor = null; + this.textFieldPlaceholderColor = null; + this.sendButtonBackgroundColor = null; + this.sendButtonIconColor = null; + this.separatorColor = null; + } +} + +class SIQLauncherTheme { + constructor() { + this.backgroundColor = null; + this.iconColor = null; + this.UnreadBadge = new SIQLauncherUnreadBadgeTheme(); + } +} + +class SIQLauncherUnreadBadgeTheme { + constructor() { + this.backgroundColor = null; + this.textColor = null; + this.borderColor = null; + this.borderWidth = null; + } +} + +class SIQLogViewTheme { + constructor() { + this.backgroundColor = null; + this.titleColor = null; + this.textViewColor = null; + this.textViewBackgroundColor = null; + this.sendTitleColor = null; + this.sendBackgroundColor = null; + this.cancelTitleColor = null; + } +} + +class SIQMessageCommonTheme { + constructor() { + this.botTypingIndicatorStyle = null; + this.messageSenderNameColor = null; + this.outgoingBackgroundColor = null; + this.outgoingTextColor = null; + this.outgoingBorderColor = null; + this.outgoingTimeTextColor = null; + this.outgoingTimeIconColor = null; + this.incomingBackgroundColor = null; + this.incomingTextColor = null; + this.incomingBorderColor = null; + this.incomingTimeTextColor = null; + this.incomingTimeIconColor = null; + this.incomingTextTimeColor = null; + this.outgoingTextTimeColor = null; + this.messageStatusIconColor = null; + this.incomingMessageEditedTagColor = null; + this.outgoingMessageEditedTagColor = null; + this.incomingMessageTimeStampColor = null; + this.outgoingMessageTimeStampColor = null; + this.incomingDeletedMessageColor = null; + this.outgoingDeletedMessageColor = null; + this.deletingMessageTitleColor = null; + this.deliveryStatusIconColor = null; + this.repliedMessageHighLightColor = null; + this.incomingMessageReplyIconColor = null; + this.outgoingMessageReplyIconColor = null; + this.incomingProgressButton = new SIQProgressButtonTheme(); + this.outgoingProgressButton = new SIQProgressButtonTheme(); + this.outgoingRepliedMessage = new SIQReplyViewTheme(); + this.incomingRepliedMessage = new SIQReplyViewTheme(); + } +} + +class SIQMessageTheme { + constructor() { + this.Common = new SIQMessageCommonTheme(); + this.Suggestion = new SIQSuggestionTheme(); + this.SkipActionButton = new SIQSkipActionButtonTheme(); + this.AudioPlayer = new SIQAudioPlayerTheme(); + this.Selection = new SIQSelectionComponentTheme(); + this.InputCard = new SIQInputCardTheme(); + this.Slider = new SIQSliderCardTheme(); + this.InfoMessage = new SIQInfoMessageTheme(); + this.Article = new SIQArticleMessageTheme(); + this.File = new SIQFileMessageTheme(); + } +} + +class SIQNavigationTheme { + constructor() { + this.backgroundColor = null; + this.titleColor = null; + this.tintColor = null; + } +} + +class SIQNoNetworkBannerTheme { + constructor() { + this.backgroundColor = null; + this.textColor = null; + this.loaderColor = null; + } +} + +class SIQOfflineBannerTheme { + constructor() { + this.textColor = null; + this.backgroundColor = null; + } +} + +class SIQProgressButtonTheme { + constructor() { + this.backgroundColor = null; + this.tintColor = null; + } +} + +class SIQQueueBannerTheme { + constructor() { + this.backgroundColor = null; + this.titleColor = null; + this.subtitleColor = null; + this.subtitleTimeColor = null; + this.positionTextColor = null; + this.positionSubtitleColor = null; + this.positionContainerBackgroundColor = null; + } +} + +class SIQReplyViewTheme { + constructor() { + this.backgroundColor = null; + this.titleColor = null; + this.subtitleColor = null; + this.verticalLine = null; + this.messageTypeIconColor = null; + this.closeButton = null; + } +} + +class SIQSelectionComponentTheme { + constructor() { + this.textColor = null; + this.accessoryColor = null; + this.backgroundColor = null; + this.selectionBackgroundColor = null; + this.buttonTextColor = null; + this.buttonBackgroundColor = null; + this.linkTextColor = null; + } +} + +class SIQSkipActionButtonTheme { + constructor() { + this.textColor = null; + this.borderColor = null; + this.backgroundColor = null; + this.cornerRadius = null; + } +} + +class SIQSliderCardTheme { + constructor() { + this.thumbBorderColor = null; + this.selectedTrackColor = null; + this.selectedValueTextColor = null; + this.unSelectedTrackColor = null; + this.thumbBackgroundColor = null; + this.minRangeTextColor = null; + this.maxRangeTextColor = null; + } +} + +class SIQSuggestionTheme { + constructor() { + this.textColor = null; + this.borderColor = null; + this.backgroundColor = null; + this.cornerRadius = null; + this.displayStyle = null; + } +} + +class SIQTabBarTheme { + constructor() { + this.backgroundColor = null; + this.activeTabColor = null; + this.inactiveTabColor = null; + } +} + +class SIQTheme { + constructor() { + this.themeColor = null; + this.Launcher = new SIQLauncherTheme(); + this.TabBar = new SIQTabBarTheme(); + this.Navigation = new SIQNavigationTheme(); + this.EmptyView = new SIQEmptyViewTheme(); + this.OfflineBanner = new SIQOfflineBannerTheme(); + this.NetworkWaitingBanner = new SIQNoNetworkBannerTheme(); + this.Conversation = new SIQConversationTheme(); + this.FAQ = new SIQFAQTheme(); + this.Chat = new SIQChatWindowTheme(); + this.Form = new SIQChatFormTheme(); + this.Feedback = new SIQFeedbackTheme(); + this.InAppNotification = new SIQInAppNotificationTheme(); + } +} + +module.exports = SIQTheme; \ No newline at end of file diff --git a/www/ZohoSalesIQ.js b/www/ZohoSalesIQ.js index e063291..e9cb8a7 100755 --- a/www/ZohoSalesIQ.js +++ b/www/ZohoSalesIQ.js @@ -31,7 +31,7 @@ exports.EVENT = { RESOURCE_LIKED: "RESOURCE_LIKED", // No I18N RESOURCE_DISLIKED: "RESOURCE_DISLIKED", // No I18N HANDLE_CUSTOM_LAUNCHER_VISIBILITY: "HANDLE_CUSTOM_LAUNCHER_VISIBILITY",// No I18N - NOTIFICATION_CLICKED: "NOTIFICATION_CLICKED",// No I18N + NOTIFICATION_CLICKED: "NOTIFICATION_CLICKED"// No I18N }; exports.Resource = { @@ -68,6 +68,12 @@ exports.Launcher = { }, enableDragToDismiss: function (enable) { exec(null, null, serviceName, 'enableLauncherDragToDismiss', [enable]); // No I18N + }, + setMinimumPressDuration: function (duration) { + exec(null, null, serviceName, 'setLauncherMinimumPressDuration', [duration]); // No I18N + }, + refresh: function () { + exec(null, null, serviceName, 'refreshLauncher', []); // No I18N } }; @@ -92,12 +98,15 @@ exports.CHATTYPE = { MISSED: "MISSED" // No I18N }; -// API Methods exports.init = function (appKey, accessKey, success, error) { exec(success, error, serviceName, 'init', [appKey, accessKey]); // No I18N setPlatform(getPluginPlatform()); }; +exports.present = function (tab = null, id = null, success, error) { + exec(success, error, serviceName, 'present', [tab, id]); // No I18N +}; + exports.enableScreenshotOption = function (success, error) { exec(success, error, serviceName, 'enableScreenshotOption', []); // No I18N }; @@ -154,6 +163,10 @@ exports.setThemeColorforiOS = function (colorCodeHex, success, error) { exec(success, error, serviceName, 'setThemeColorforiOS', [colorCodeHex]); // No I18N }; +exports.setThemeForiOS = function (colors, success, error) { + exec(success, error, serviceName, 'setThemeForiOS', [colors]); // No I18N +}; + exports.endChat = function (chatID, success, error) { exec(success, error, serviceName, 'endChat', [chatID]); // No I18N }; @@ -248,6 +261,7 @@ exports.setQuestion = function (question, success, error) { exec(success, error, serviceName, 'setQuestion', [question]); // No I18N }; +// Deprecated exports.startChat = function (question, success, error) { exec(success, error, serviceName, 'startChat', [question]); // No I18N }; @@ -281,9 +295,9 @@ exports.enableInAppNotification = function (success, error) { exports.disableInAppNotification = function (success, error) { exec(success, error, serviceName, 'disableInAppNotification', []); // No I18N }; - -exports.registerLocalizationFileForiOS = function (name, success, error) { - exec(success, error, serviceName, 'registerLocalizationFile', [name]); // No I18N + +exports.registerLocalizationFileForiOS = function (name) { + exec(null, null, serviceName, 'registerLocalizationFile', [name]); // No I18N }; //CONVERSATIONN APIS @@ -403,6 +417,21 @@ exports.Chat = { }, isChatEnabled: function (success) { exec(success, null, serviceName, 'isChatEnabled', []); // No I18N + }, + open: function (map) { + exec(null, null, serviceName, 'openChat', [map]); // No I18N + }, + start: function (question, customChatId = null, departmentName = null, success, error) { + exec(success, error, serviceName, 'startNewChat', [question, customChatId, departmentName]); // No I18N + }, + startWithTrigger: function (customChatId = null, departmentName = null, success, error) { + exec(success, error, serviceName, 'startNewChatWithTrigger', [customChatId, departmentName]); // No I18N + }, + setWaitingTime: function (seconds) { + exec(null, null, serviceName, 'setChatWaitingTime', [seconds]); // No I18N + }, + get: function (chatId, success, error) { + exec(success, error, serviceName, 'getChat', [chatId]); // No I18N } }; @@ -426,7 +455,7 @@ exports.Notification = { exec(success, error, serviceName, 'isSDKMessage', [payload]); // No I18N }, registerPush: function (token, isTestDevice) { - exec(null, null,serviceName, 'registerPush', [token, isTestDevice]); // No I18N + exec(null, null, serviceName, 'registerPush', [token, isTestDevice]); // No I18N }, getPayload: function (payload, success, error) { exec(success, error, serviceName, 'getNotificationPayload', [payload]); // No I18N @@ -458,34 +487,34 @@ exports.Logger = { exports.KnowledgeBase = { isEnabled: function (type, success, error) { - exec(success, error, serviceName, 'isKnowledgeBaseEnabled', [type]); // No I18N + exec(success, error, serviceName, 'isKnowledgeBaseEnabled', [type]); // No I18N }, setVisibility: function (type, shouldShow) { - exec(null, null, serviceName, 'setKnowledgeBaseVisibility', [type, shouldShow]); // No I18N + exec(null, null, serviceName, 'setKnowledgeBaseVisibility', [type, shouldShow]); // No I18N }, categorize: function (type, shouldCategorize) { - exec(null, null, serviceName, 'categorizeKnowledgeBase',[type, shouldCategorize]); // No I18N + exec(null, null, serviceName, 'categorizeKnowledgeBase', [type, shouldCategorize]); // No I18N }, combineDepartments: function (type, merge) { - exec(null, null, serviceName, 'combineKnowledgeBaseDepartments', [type, merge]); // No I18N + exec(null, null, serviceName, 'combineKnowledgeBaseDepartments', [type, merge]); // No I18N }, setRecentlyViewedCount: function (limit) { - exec(null, null, serviceName, 'setKnowledgeBaseRecentlyViewedCount', [limit]); // No I18N + exec(null, null, serviceName, 'setKnowledgeBaseRecentlyViewedCount', [limit]); // No I18N }, getResourceDepartments: function (success, error) { - exec(success, error, serviceName, 'getKnowledgeBaseResourceDepartments', []); // No I18N + exec(success, error, serviceName, 'getKnowledgeBaseResourceDepartments', []); // No I18N }, open: function (type, id, success, error) { - exec(success, error, serviceName, 'openKnowledgeBase', [type, id]); // No I18N + exec(success, error, serviceName, 'openKnowledgeBase', [type, id]); // No I18N }, getSingleResource: function (type, id, success, error) { - exec(success, error, serviceName, 'getKnowledgeBaseSingleResource', [type, id]); // No I18N + exec(success, error, serviceName, 'getKnowledgeBaseSingleResource', [type, id]); // No I18N }, getResources: function (type, departmentId = null, parentCategoryId = null, page = 1, limit = 99, searchKey = null, success, error) { - exec(success, error, serviceName, 'getKnowledgeBaseResources',[type, departmentId, parentCategoryId, page, limit, searchKey]); // No I18N + exec(success, error, serviceName, 'getKnowledgeBaseResources', [type, departmentId, parentCategoryId, page, limit, searchKey]); // No I18N }, getCategories: function (type, departmentId = null, parentCategoryId = null, success, error) { - exec(success, error, serviceName, 'getKnowledgeBaseCategories',[type, departmentId, parentCategoryId]); // No I18N + exec(success, error, serviceName, 'getKnowledgeBaseCategories', [type, departmentId, parentCategoryId]); // No I18N } }; @@ -520,6 +549,6 @@ function parseResult(input) { } }; -window.addEventListener('orientationchange', function() { +window.addEventListener('orientationchange', function () { exec(null, null, serviceName, 'refreshLauncher', []); // No I18N }); \ No newline at end of file