diff --git a/android/src/main/java/com/zohosalesiq/plugin/MobilistenPlugin.java b/android/src/main/java/com/zohosalesiq/plugin/MobilistenPlugin.java index 6f3f826..422b7ab 100644 --- a/android/src/main/java/com/zohosalesiq/plugin/MobilistenPlugin.java +++ b/android/src/main/java/com/zohosalesiq/plugin/MobilistenPlugin.java @@ -87,15 +87,11 @@ public class MobilistenPlugin implements FlutterPlugin, MethodCallHandler, Activ private static Hashtable actionsList = new Hashtable<>(); - Handler handler; - @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "salesiq_mobilisten"); // No I18N channel.setMethodCallHandler(this); - handler = new Handler(Looper.getMainLooper()); - eventChannel = new EventChannel(flutterPluginBinding.getBinaryMessenger(), mobilistenEventChannel); chatEventChannel = new EventChannel(flutterPluginBinding.getBinaryMessenger(), mobilistenChatEventChannel); faqEventChannel = new EventChannel(flutterPluginBinding.getBinaryMessenger(), mobilistenFAQEventChannel); @@ -156,48 +152,51 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result rawResult) { case "showLauncher": ZohoSalesIQ.showLauncher(LiveChatUtil.getBoolean(call.arguments)); - handler = new Handler(Looper.getMainLooper()); - handler.post(new Runnable() { - public void run() { - if (activity != null) { - ZohoSalesIQ.getApplicationManager().setCurrentActivity(activity); - ZohoSalesIQ.getApplicationManager().refreshChatBubble(); - } - } - }); + ZohoSalesIQ.getApplicationManager().setCurrentActivity(activity); + ZohoSalesIQ.getApplicationManager().refreshChatBubble(); + + finalResult.success(null); break; case "setLanguage": ZohoSalesIQ.Chat.setLanguage(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "setDepartment": ZohoSalesIQ.Chat.setDepartment(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "setDepartments": ArrayList deptList = (ArrayList) call.arguments; ZohoSalesIQ.Chat.setDepartments(deptList); + finalResult.success(null); break; case "setQuestion": ZohoSalesIQ.Visitor.setQuestion(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "startChat": ZohoSalesIQ.Visitor.startChat(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "setConversationVisibility": ZohoSalesIQ.Conversation.setVisibility(LiveChatUtil.getBoolean(call.arguments)); + finalResult.success(null); break; case "setConversationListTitle": ZohoSalesIQ.Conversation.setTitle(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "setFAQVisibility": ZohoSalesIQ.FAQ.setVisibility(LiveChatUtil.getBoolean(call.arguments)); + finalResult.success(null); break; case "registerVisitor": @@ -216,27 +215,33 @@ public void onFailure(int errorCode, String errorMessage) { case "unregisterVisitor": //need to pass the current activity ZohoSalesIQ.unregisterVisitor(activity); //need to pass the current activity + finalResult.success(null); break; case "setPageTitle": ZohoSalesIQ.Tracking.setPageTitle(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "performCustomAction": ZohoSalesIQ.Tracking.setCustomAction(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "enableInAppNotification": ZohoSalesIQ.Notification.enableInApp(); + finalResult.success(null); break; case "disableInAppNotification": ZohoSalesIQ.Notification.disableInApp(); + finalResult.success(null); break; case "setOperatorEmail": try { ZohoSalesIQ.Chat.setOperatorEmail(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); } catch (InvalidEmailException e) { finalResult.error("10001", e.getMessage(), null); // No I18N } @@ -244,40 +249,49 @@ public void onFailure(int errorCode, String errorMessage) { case "show": ZohoSalesIQ.Chat.show(); + finalResult.success(null); break; case "openChatWithID": ZohoSalesIQ.Chat.open(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "openNewChat": ZohoSalesIQ.Chat.openNewChat(); + finalResult.success(null); break; case "showOfflineMessage": ZohoSalesIQ.Chat.showOfflineMessage(LiveChatUtil.getBoolean(call.arguments)); + finalResult.success(null); break; case "endChat": ZohoSalesIQ.Chat.endChat(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "setVisitorName": ZohoSalesIQ.Visitor.setName(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "setVisitorEmail": ZohoSalesIQ.Visitor.setEmail(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "setVisitorContactNumber": ZohoSalesIQ.Visitor.setContactNumber(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "setVisitorAddInfo": String key = LiveChatUtil.getString(call.argument("key")); // No I18N String value = LiveChatUtil.getString(call.argument("value")); // No I18N ZohoSalesIQ.Visitor.addInfo(key, value); + finalResult.success(null); break; case "setVisitorLocation": @@ -307,73 +321,67 @@ public void onFailure(int errorCode, String errorMessage) { siqVisitorLocation.setZipCode(LiveChatUtil.getString(visitorLocation.get("zipCode"))); // No I18N } ZohoSalesIQ.Visitor.setLocation(siqVisitorLocation); + finalResult.success(null); } break; case "setChatTitle": ZohoSalesIQ.Chat.setTitle(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "showOperatorImageInLauncher": ZohoSalesIQ.Chat.showOperatorImageInLauncher(LiveChatUtil.getBoolean(call.arguments)); + finalResult.success(null); break; case "showOperatorImageInChat": ZohoSalesIQ.Chat.setVisibility(ChatComponent.operatorImage, LiveChatUtil.getBoolean(call.arguments)); + finalResult.success(null); break; case "setVisitorNameVisibility": ZohoSalesIQ.Chat.setVisibility(ChatComponent.visitorName, LiveChatUtil.getBoolean(call.arguments)); + finalResult.success(null); break; case "setFeedbackVisibility": ZohoSalesIQ.Chat.setVisibility(ChatComponent.feedback, LiveChatUtil.getBoolean(call.arguments)); + finalResult.success(null); break; case "setRatingVisibility": ZohoSalesIQ.Chat.setVisibility(ChatComponent.rating, LiveChatUtil.getBoolean(call.arguments)); + finalResult.success(null); break; case "enablePreChatForms": ZohoSalesIQ.Chat.setVisibility(ChatComponent.prechatForm, true); + finalResult.success(null); break; case "disablePreChatForms": ZohoSalesIQ.Chat.setVisibility(ChatComponent.prechatForm, false); + finalResult.success(null); break; case "getDepartments": - handler = new Handler(Looper.getMainLooper()); - handler.post(new Runnable(){ - public void run(){ - ZohoSalesIQ.Chat.getDepartments(new DepartmentListener() { - @Override - public void onSuccess(ArrayList arrayList) { - if (arrayList != null){ - final List> departmentList = new ArrayList>(); - for (int i=0; i chatMapObject = getDepartmentMapObject(arrayList.get(i)); - departmentList.add(chatMapObject); - } - handler.post(new Runnable() { - @Override - public void run() { - finalResult.success(departmentList); - } - }); - } + ZohoSalesIQ.Chat.getDepartments(new DepartmentListener() { + @Override + public void onSuccess(ArrayList arrayList) { + if (arrayList != null){ + final List> departmentList = new ArrayList>(); + for (int i=0; i chatMapObject = getDepartmentMapObject(arrayList.get(i)); + departmentList.add(chatMapObject); } + finalResult.success(departmentList); + } + } - @Override - public void onFailure(final int errorCode, final String errorMessage) { - handler.post(new Runnable() { - @Override - public void run() { - finalResult.error(LiveChatUtil.getString(errorCode), errorMessage, null); - } - }); - } - }); + @Override + public void onFailure(final int errorCode, final String errorMessage) { + finalResult.error(LiveChatUtil.getString(errorCode), errorMessage, null); } }); break; @@ -423,31 +431,22 @@ public void onFailure(int errorCode, String message) { break; case "getArticles": - handler.post(new Runnable() { - public void run() { - ZohoSalesIQ.FAQ.getArticles(new FAQListener() { - @Override - public void onSuccess(ArrayList arrayList) { - if (arrayList != null){ - final List> articleList = new ArrayList>(); - for (int i = 0; i < arrayList.size(); i++) { - Map chatMapObject = getArticleMapObject(arrayList.get(i)); - articleList.add(chatMapObject); - } - handler.post(new Runnable() { - @Override - public void run() { - finalResult.success(articleList); - } - }); - } + ZohoSalesIQ.FAQ.getArticles(new FAQListener() { + @Override + public void onSuccess(ArrayList arrayList) { + if (arrayList != null){ + final List> articleList = new ArrayList>(); + for (int i = 0; i < arrayList.size(); i++) { + Map chatMapObject = getArticleMapObject(arrayList.get(i)); + articleList.add(chatMapObject); } + finalResult.success(articleList); + } + } - @Override - public void onFailure(int code, String message) { - finalResult.error(""+code, message, null); - } - }); + @Override + public void onFailure(int code, String message) { + finalResult.error(""+code, message, null); } }); break; @@ -463,12 +462,7 @@ public void onSuccess(ArrayList arrayList) { Map chatMapObject = getArticleMapObject(arrayList.get(i)); articleList.add(chatMapObject); } - handler.post(new Runnable() { - @Override - public void run() { - finalResult.success(articleList); - } - }); + finalResult.success(articleList); } } @@ -494,22 +488,12 @@ public void onSuccess(ArrayList arrayList) { categoryList.add(categoryMap); } } - handler.post(new Runnable() { - @Override - public void run() { - finalResult.success(categoryList); - } - }); + finalResult.success(categoryList); } @Override public void onFailure(final int errorCode, final String errorMessage) { - handler.post(new Runnable() { - @Override - public void run() { - finalResult.error(LiveChatUtil.getString(errorCode), errorMessage, null); - } - }); + finalResult.error(LiveChatUtil.getString(errorCode), errorMessage, null); } }); break; @@ -558,76 +542,67 @@ public void onFailure(int code, String message) { case "registerChatAction": UUID uuid = UUID.randomUUID(); ZohoLiveChat.ChatActions.register(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "unregisterChatAction": ZohoLiveChat.ChatActions.unregister(LiveChatUtil.getString(call.arguments)); + finalResult.success(null); break; case "unregisterAllChatActions": ZohoLiveChat.ChatActions.unregisterAll(); + finalResult.success(null); break; case "setChatActionTimeout": final long timeout = LiveChatUtil.getLong(call.arguments); - handler = new Handler(Looper.getMainLooper()); - handler.post(new Runnable() { - public void run() { - ZohoSalesIQ.ChatActions.setTimeout(timeout*1000); - } - }); + ZohoSalesIQ.ChatActions.setTimeout(timeout*1000); + finalResult.success(null); break; - case "completeChatAction": + case "completeChatAction": { final String actionID = LiveChatUtil.getString(call.arguments); - handler = new Handler(Looper.getMainLooper()); - handler.post(new Runnable() { - public void run() { - SalesIQCustomActionListener listener; - listener = actionsList.get(actionID); - if (listener != null){ - listener.onSuccess(); - } - if (actionsList != null) { - actionsList.remove(actionID); - } - } - }); + SalesIQCustomActionListener actionListener = actionsList.get(actionID); + if (actionListener != null){ + actionListener.onSuccess(); + } + if (actionsList != null) { + actionsList.remove(actionID); + } + finalResult.success(null); break; - - case "completeChatActionWithMessage": + } + case "completeChatActionWithMessage": { final String actionId = LiveChatUtil.getString(call.argument("actionUUID")); // No I18N final boolean state = LiveChatUtil.getBoolean(call.argument("state")); // No I18N final String message = LiveChatUtil.getString(call.argument("message")); // No I18N - Handler handler1 = new Handler(Looper.getMainLooper()); - handler1.post(new Runnable() { - public void run() { - SalesIQCustomActionListener listener = actionsList.get(actionId); - if (listener != null){ - if (state) { - if (message != null && message.length() > 0) { - listener.onSuccess(message); - } - else{ - listener.onSuccess(); - } - } - else{ - if (message != null && message.length() > 0) { - listener.onFailure(message); - } - else{ - listener.onFailure(); - } - } + + SalesIQCustomActionListener actionListener = actionsList.get(actionId); + if (actionListener != null){ + if (state) { + if (message != null && message.length() > 0) { + actionListener.onSuccess(message); } - if (actionsList != null) { - actionsList.remove(actionId); + else{ + actionListener.onSuccess(); } } - }); + else{ + if (message != null && message.length() > 0) { + actionListener.onFailure(message); + } + else{ + actionListener.onFailure(); + } + } + } + if (actionsList != null) { + actionsList.remove(actionId); + } + finalResult.success(null); break; - + } case "isMultipleOpenChatRestricted": finalResult.success(ZohoLiveChat.Chat.isMultipleOpenRestricted()); break; diff --git a/ios/Classes/SwiftMobilistenPlugin.swift b/ios/Classes/SwiftMobilistenPlugin.swift index 25573af..94ecf2a 100644 --- a/ios/Classes/SwiftMobilistenPlugin.swift +++ b/ios/Classes/SwiftMobilistenPlugin.swift @@ -148,38 +148,47 @@ public class SwiftMobilistenPlugin: NSObject, FlutterPlugin { case "showLauncher": if let show = argument as? Bool { ZohoSalesIQ.showLauncher(show) + result(nil) } case "setLanguage": if let code = argument as? String { ZohoSalesIQ.Chat.setLanguageWithCode(code) + result(nil) } case "setDepartment": if let department = argument as? String { ZohoSalesIQ.Chat.setDepartment(department) + result(nil) } case "setDepartments": if let departments = argument as? [String] { ZohoSalesIQ.Chat.setDepartments(departments) + result(nil) } case "setQuestion": if let question = argument as? String { ZohoSalesIQ.Visitor.setQuestion(question) + result(nil) } case "startChat": if let question = argument as? String { ZohoSalesIQ.Chat.startChat(question: question) + result(nil) } case "setConversationVisibility": if let show = argument as? Bool { ZohoSalesIQ.Conversation.setVisibility(show) + result(nil) } case "setConversationListTitle": if let title = argument as? String { ZohoSalesIQ.Conversation.setTitle(title) + result(nil) } case "setFAQVisibility": if let show = argument as? Bool { ZohoSalesIQ.FAQ.setVisibility(show) + result(nil) } case "registerVisitor": if let id = argument as? String { @@ -202,92 +211,117 @@ public class SwiftMobilistenPlugin: NSObject, FlutterPlugin { case "setPageTitle": if let pageTitle = argument as? String { ZohoSalesIQ.Tracking.setPageTitle(pageTitle) + result(nil) } case "performCustomAction": if let customAction = argument as? String { ZohoSalesIQ.Visitor.performCustomAction(customAction) + result(nil) } case "enableInAppNotification": ZohoSalesIQ.Chat.setVisibility(.inAppNotifications, visible: true) + result(nil) case "disableInAppNotification": ZohoSalesIQ.Chat.setVisibility(.inAppNotifications, visible: false) case "setOperatorEmail": if let operatorEmail = argument as? String { ZohoSalesIQ.Chat.setAgentEmail(operatorEmail) + result(nil) } case "show": ZohoSalesIQ.Chat.show() + result(nil) case "openChatWithID": if let id = argument as? String { ZohoSalesIQ.Chat.show(referenceID: id, new: false) + result(nil) } case "openNewChat": ZohoSalesIQ.Chat.show(new: true) + result(nil) case "showOfflineMessage": if let show = argument as? Bool { ZohoSalesIQ.Chat.showOfflineMessage(show) + result(nil) } case "endChat": if let id = argument as? String { ZohoSalesIQ.Chat.endSession(referenceID: id) + result(nil) } case "setVisitorName": if let name = argument as? String { ZohoSalesIQ.Visitor.setName(name) + result(nil) } case "setVisitorEmail": if let email = argument as? String { ZohoSalesIQ.Visitor.setEmail(email) + result(nil) } case "setVisitorContactNumber": if let phone = argument as? String { ZohoSalesIQ.Visitor.setContactNumber(phone) + result(nil) } case "setVisitorAddInfo": if let args = call.argumentDictionary, let key = args["key"] as? String, let value = args["value"] as? String { ZohoSalesIQ.Visitor.addInfo(key, value: value) + result(nil) } case "setVisitorLocation": if let args = argument as? [String: AnyObject] { ZohoSalesIQ.Visitor.setLocation(getVisitorLocation(using: args)) + result(nil) } case "setChatTitle": if let title = argument as? String { ZohoSalesIQ.Chat.setTitle(title) + result(nil) } case "showOperatorImageInLauncher": if let show = argument as? Bool { ZohoSalesIQ.Chat.setVisibility(.attenderImageOnLauncher, visible: show) + result(nil) } case "showOperatorImageInChat": if let show = argument as? Bool { ZohoSalesIQ.Chat.setVisibility(.attenderImageInChat, visible: show) + result(nil) } case "setVisitorNameVisibility": if let show = argument as? Bool { ZohoSalesIQ.Chat.setVisibility(.visitorName, visible: show) + result(nil) } case "setFeedbackVisibility": if let show = argument as? Bool { ZohoSalesIQ.Chat.setVisibility(.feedback, visible: show) + result(nil) } case "setRatingVisibility": if let show = argument as? Bool { ZohoSalesIQ.Chat.setVisibility(.rating, visible: show) + result(nil) } case "enableScreenshotOption": ZohoSalesIQ.Chat.setVisibility(.screenshotOption, visible: true) + result(nil) case "disableScreenshotOption": ZohoSalesIQ.Chat.setVisibility(.screenshotOption, visible: false) + result(nil) case "enablePreChatForms": ZohoSalesIQ.Chat.setVisibility(.preChatForm, visible: true) + result(nil) case "disablePreChatForms": ZohoSalesIQ.Chat.setVisibility(.preChatForm, visible: false) + result(nil) case "setThemeColorForiOS": if let colorCode = argument as? String, let themeColor = UIColor(hex: colorCode) { let theme = ZohoSalesIQ.Theme.baseTheme theme.themeColor = themeColor ZohoSalesIQ.Theme.setTheme(theme: theme) + result(nil) } case "getChats", "getChatsWithFilter": var status: ChatStatus = .all @@ -392,20 +426,24 @@ public class SwiftMobilistenPlugin: NSObject, FlutterPlugin { self.sendChatEvent(name: .performChatAction, dataLabel: "chatAction", data: arg) } ZohoSalesIQ.ChatActions.register(action: action) + result(nil) } else { result(operationFailedError) } case "unregisterChatAction": if let name = argument as? String { ZohoSalesIQ.ChatActions.unregisterWithName(name: name) + result(nil) } else { result(operationFailedError) } case "unregisterAllChatActions": ZohoSalesIQ.ChatActions.unregisterAll() + result(nil) case "setChatActionTimeout": if let time = argument as? Int { ZohoSalesIQ.ChatActions.setTimeout(Double(time)) + result(nil) } else { result(operationFailedError) } @@ -413,6 +451,7 @@ public class SwiftMobilistenPlugin: NSObject, FlutterPlugin { if let uuid = argument as? String, let handler = chatActionStore[uuid] { handler.success() chatActionStore.removeValue(forKey: uuid) + result(nil) } else { result(operationFailedError) } @@ -425,6 +464,7 @@ public class SwiftMobilistenPlugin: NSObject, FlutterPlugin { handler.faliure(message: msg) } chatActionStore.removeValue(forKey: uuid) + result(nil) } else { result(operationFailedError) } @@ -436,18 +476,21 @@ public class SwiftMobilistenPlugin: NSObject, FlutterPlugin { if let args = argument as? [String: Any], let token = args["token"] as? String, let isTestDevice = args["isTestDevice"] as? Bool, let productionMode = args["productionMode"] as? Bool { let apnsMode: APNSMode = productionMode ? .production : .sandbox ZohoSalesIQ.enablePush(token, isTestDevice: isTestDevice, mode: apnsMode) + result(nil) } else { result(operationFailedError) } case "handleNotificationResponseForiOS": if let userInfo = argument as? [AnyHashable: Any] { ZohoSalesIQ.handleNotificationResponse(userInfo) + result(nil) } else { result(operationFailedError) } case "processNotificationWithInfoForiOS": if let userInfo = argument as? [AnyHashable: Any] { ZohoSalesIQ.processNotificationWithInfo(userInfo) + result(nil) } else { result(operationFailedError) } diff --git a/lib/salesiq_mobilisten.dart b/lib/salesiq_mobilisten.dart index 19193bf..21fb14b 100644 --- a/lib/salesiq_mobilisten.dart +++ b/lib/salesiq_mobilisten.dart @@ -1,4 +1,5 @@ import 'dart:async'; + import 'package:flutter/services.dart'; class ZohoSalesIQ { @@ -23,7 +24,7 @@ class ZohoSalesIQ { EventChannel(_mobilistenArticleEventChannel).receiveBroadcastStream(); /// Initializes Mobilisten using the [appKey] and [accessKey] generated for the bundle ID/package name of an application. - static Future init(String appKey, String accessKey) async { + static Future init(String appKey, String accessKey) async { Map args = {}; args.putIfAbsent("appKey", () => appKey); args.putIfAbsent("accessKey", () => accessKey); @@ -31,47 +32,47 @@ class ZohoSalesIQ { } /// Controls the visibility of the default launcher using the value provided for [show]. - static Future showLauncher(bool show) async { + static Future showLauncher(bool show) async { await _channel.invokeMethod('showLauncher', show); } /// Sets the language used by Mobilisten using the language code provided in [language]. - static Future setLanguage(String language) async { + static Future setLanguage(String language) async { await _channel.invokeMethod('setLanguage', language); } /// Sets the department to which all chat requests are routed by default. - static Future setDepartment(String department) async { + static Future setDepartment(String department) async { await _channel.invokeMethod('setDepartment', department); } /// Sets the list of departments to which chat requests may be routed. - static Future setDepartments(List departmentList) async { + static Future setDepartments(List departmentList) async { await _channel.invokeMethod('setDepartments', departmentList); } /// Prefills the text provided as [question] in the chat input field for a new chat window. - static Future setQuestion(String question) async { + static Future setQuestion(String question) async { await _channel.invokeMethod('setQuestion', question); } /// Automatically attempts to starts a chat using the text provided in [question] as the question. - static Future startChat(String question) async { + static Future startChat(String question) async { await _channel.invokeMethod('startChat', question); } /// Enables or disables conversation history using the value provided for [visibility]. - static Future setConversationVisibility(bool visibility) async { + static Future setConversationVisibility(bool visibility) async { await _channel.invokeMethod('setConversationVisibility', visibility); } /// Sets the title for the conversations list. - static Future setConversationListTitle(String title) async { + static Future setConversationListTitle(String title) async { await _channel.invokeMethod('setConversationListTitle', title); } /// Enables or disables the FAQs/the Knowledge base using the value provided for [visibility]. - static Future setFAQVisibility(bool visibility) async { + static Future setFAQVisibility(bool visibility) async { await _channel.invokeMethod('setFAQVisibility', visibility); } @@ -84,79 +85,79 @@ class ZohoSalesIQ { /// Unregisters and clears conversations and data for the current user. /// Use the API during a `logout` operation to clear data. - static Future unregisterVisitor() async { + static Future unregisterVisitor() async { await _channel.invokeMethod('unregisterVisitor'); } /// Sets the current page title to be shown in the visitor footpath on the SalesIQ console. - static Future setPageTitle(String pageTitle) async { + static Future setPageTitle(String pageTitle) async { await _channel.invokeMethod('setPageTitle', pageTitle); } /// Performs a custom action using the action name provided in [actionName]. - static Future performCustomAction(String actionName) async { + static Future performCustomAction(String actionName) async { await _channel.invokeMethod('performCustomAction', actionName); } /// Enables in-app notifications from Mobilisten if previously disabled. /// In-app notifications are `enabled` by default. - static Future enableInAppNotification() async { + static Future enableInAppNotification() async { await _channel.invokeMethod('enableInAppNotification'); } /// Disables in-app notifications from Mobilisten. - static Future disableInAppNotification() async { + static Future disableInAppNotification() async { await _channel.invokeMethod('disableInAppNotification'); } /// Sets the operator to whom all chat requests need to be routed using the provided [email]. - static Future setOperatorEmail(String email) async { + static Future setOperatorEmail(String email) async { await _channel.invokeMethod('setOperatorEmail', email); } /// Opens the Mobilisten UI. Invoke this API only after initialization is complete. - static Future show() async { + static Future show() async { await _channel.invokeMethod('show'); } /// Opens the chat window for a specified chat if provided the [chatID]. - static Future openChatWithID(String chatID) async { + static Future openChatWithID(String chatID) async { await _channel.invokeMethod('openChatWithID', chatID); } /// Opens a new chat window for creating a new chat. - static Future openNewChat() async { + static Future openNewChat() async { await _channel.invokeMethod('openNewChat'); } /// Shows an offline banner if all departments are offline. /// This API is indended for use only when then chat waiting time is set to `Infinite`. - static Future showOfflineMessage(bool show) async { + static Future showOfflineMessage(bool show) async { await _channel.invokeMethod('showOfflineMessage', show); } /// Ends the specified chat if provided the [chatID]. - static Future endChat(String chatID) async { + static Future endChat(String chatID) async { await _channel.invokeMethod('endChat', chatID); } /// Sets the visitor's name. - static Future setVisitorName(String visitorName) async { + static Future setVisitorName(String visitorName) async { await _channel.invokeMethod('setVisitorName', visitorName); } /// Sets the visitor's email. - static Future setVisitorEmail(String visitorEmail) async { + static Future setVisitorEmail(String visitorEmail) async { await _channel.invokeMethod('setVisitorEmail', visitorEmail); } /// Sets the visitor's contact number. - static Future setVisitorContactNumber(String contactNumber) async { + static Future setVisitorContactNumber(String contactNumber) async { await _channel.invokeMethod('setVisitorContactNumber', contactNumber); } /// Sets the visitor's custom information as [key], [value] pairs. - static Future setVisitorAddInfo(String key, String value) async { + static Future setVisitorAddInfo(String key, String value) async { Map addInfo = {}; addInfo.putIfAbsent("key", () => key); addInfo.putIfAbsent("value", () => value); @@ -164,7 +165,7 @@ class ZohoSalesIQ { } /// Sets the visitor's secondary location. - static Future setVisitorLocation( + static Future setVisitorLocation( SIQVisitorLocation locationDetails) async { Map location = {}; location.putIfAbsent("latitude", () => locationDetails.latitude); @@ -178,57 +179,57 @@ class ZohoSalesIQ { } /// Sets the title displayed in the chat window prior to starting a conversation. - static Future setChatTitle(String chatTitle) async { + static Future setChatTitle(String chatTitle) async { await _channel.invokeMethod('setChatTitle', chatTitle); } /// Sets the overall theme color used in the iOS platform. - static Future setThemeColorForiOS(String hexColor) async { + static Future setThemeColorForiOS(String hexColor) async { await _channel.invokeMethod('setThemeColorForiOS', hexColor); } /// Enables showing the operator's image in the default launcher. - static Future showOperatorImageInLauncher(bool show) async { + static Future showOperatorImageInLauncher(bool show) async { await _channel.invokeMethod('showOperatorImageInLauncher', show); } /// Enables or disables the display of sender images for incoming messages based on the value provided for [show]. - static Future showOperatorImageInChat(bool show) async { + static Future showOperatorImageInChat(bool show) async { await _channel.invokeMethod('showOperatorImageInChat', show); } /// Enables or disables showing the visitor name _if available_ as the sender name for outgoing messages within chat. - static Future setVisitorNameVisibility(bool visibility) async { + static Future setVisitorNameVisibility(bool visibility) async { await _channel.invokeMethod('setVisitorNameVisibility', visibility); } /// Enables or disables the option to provide feedback for a chat once ended. - static Future setFeedbackVisibility(bool visibility) async { + static Future setFeedbackVisibility(bool visibility) async { await _channel.invokeMethod('setFeedbackVisibility', visibility); } /// Enables or disables the option to provide rating for a chat once ended. - static Future setRatingVisibility(bool visibility) async { + static Future setRatingVisibility(bool visibility) async { await _channel.invokeMethod('setRatingVisibility', visibility); } /// Enables the option to capture screenshots from the attachments menu. - static Future enableScreenshotOption() async { + static Future enableScreenshotOption() async { await _channel.invokeMethod('enableScreenshotOption'); } /// Disables the option to capture screenshots fromm the attachments menu. - static Future disableScreenshotOption() async { + static Future disableScreenshotOption() async { await _channel.invokeMethod('disableScreenshotOption'); } /// Enables the pre-chat form if previously disables. Pre-chat forms are `enabled` by default. - static Future enablePreChatForms() async { + static Future enablePreChatForms() async { await _channel.invokeMethod('enablePreChatForms'); } /// Disables the pre-chat form. - static Future disablePreChatForms() async { + static Future disablePreChatForms() async { await _channel.invokeMethod('disablePreChatForms'); } @@ -292,33 +293,33 @@ class ZohoSalesIQ { } /// Registers a chat action to be used in display-cards using an action name. - static Future registerChatAction(String actionName) async { + static Future registerChatAction(String actionName) async { await _channel.invokeMethod('registerChatAction', actionName); } /// Unregisters a chat action to be used in display-cards using an action name. - static Future unregisterChatAction(String actionName) async { + static Future unregisterChatAction(String actionName) async { await _channel.invokeMethod('unregisterChatAction', actionName); } /// Unregisters all registered chat action to be used in display-cards. - static Future unregisterAllChatActions() async { + static Future unregisterAllChatActions() async { await _channel.invokeMethod('unregisterAllChatActions'); } /// Sets the timeout for all chat actions. - static Future setChatActionTimeout(int timeout) async { + static Future setChatActionTimeout(int timeout) async { await _channel.invokeMethod('setChatActionTimeout', timeout); } /// Marks a chat action as complete provided the [actionUUID]. - static Future completeChatAction(String actionUUID) async { + static Future completeChatAction(String actionUUID) async { await _channel.invokeMethod('completeChatAction', actionUUID); } /// Enables push notifications for iOS using [token], [isTestDevice] and [productionMode]. /// Set [isTestDevice] to `false` and [productionMode] to `true` before moving the app to production. - static Future enablePushForiOS( + static Future enablePushForiOS( String token, bool isTestDevice, bool productionMode) async { Map args = {}; args.putIfAbsent("token", () => token); @@ -329,18 +330,18 @@ class ZohoSalesIQ { /// Processes the content of push notifications in response to a the tap action in iOS. /// Use this API only if push notification configuration is to be done manually in dart. - static Future handleNotificationResponseForiOS(Map userInfo) async { + static Future handleNotificationResponseForiOS(Map userInfo) async { await _channel.invokeMethod('handleNotificationResponseForiOS', userInfo); } /// Processes the content of push notification received for iOS. /// Use this API only if push notification configuration is to be done manually in dart. - static Future processNotificationWithInfoForiOS(Map userInfo) async { + static Future processNotificationWithInfoForiOS(Map userInfo) async { await _channel.invokeMethod('processNotificationWithInfoForiOS', userInfo); } /// Marks a chat action as complete provided the [actionUUID], completion state and the message to be shown upon completion. - static Future completeChatActionWithMessage( + static Future completeChatActionWithMessage( String actionUUID, bool state, String message) async { Map chatActionDetails = {}; chatActionDetails.putIfAbsent("actionUUID", () => actionUUID);