Skip to content

Commit

Permalink
Release v7.0.1
Browse files Browse the repository at this point in the history
Release v7.0.1
  • Loading branch information
yeskay-zohocorp committed May 6, 2024
1 parent 067d19e commit 45a1c2f
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![SupportedLanguages](https://img.shields.io/badge/Platforms-iOS%20%7C%20%20Android-green.svg)](https://www.zoho.com/salesiq/help/developer-section/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)
[![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.1-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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-zohosalesiq-mobilisten",
"version": "7.0.0",
"version": "7.0.1",
"description": "A Cordova plugin for the Zoho SalesIQ Mobilisten SDK",
"cordova": {
"id": "cordova-zohosalesiq-mobilisten",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<source url="https://github.com/CocoaPods/Specs.git" />
</config>
<pods use-frameworks="true">
<pod name="Mobilisten" spec="8.0.0" />
<pod name="Mobilisten" spec="8.1.3" />
</pods>
</podspec>
<config-file parent="/*" target="config.xml">
Expand Down
13 changes: 13 additions & 0 deletions src/android/ZohoSalesIQPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,24 @@ public static void handleMethodCalls(String action, JSONArray data, CallbackCont
ZohoSalesIQ.Chat.showFeedbackAfterSkip(LiveChatUtil.getBoolean(data.get(0)));
} else if (action.equals("showChatFeedbackUpTo")) { // No I18N
ZohoSalesIQ.Chat.showFeedback(LiveChatUtil.getInteger(data.get(0)));
} else if (action.contains("isChatEnabled")) {
Chat.isChatEnabled(callbackContext);
}
} catch (JSONException e) {
throw new RuntimeException(e);
}
}

private static void isChatEnabled(CallbackContext callbackContext) {
Boolean status = ZohoSalesIQ.isSDKEnabled();
if (callbackContext != null) {
if (status) {
callbackContext.success(1);
} else {
callbackContext.success(0);
}
}
}
}

static class Launcher {
Expand Down
103 changes: 100 additions & 3 deletions src/ios/ZohoSalesIQPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ @implementation ZohoSalesIQPlugin

NSString *HANDLE_CUSTOM_LAUNCHER_VISIBILITY = @"HANDLE_CUSTOM_LAUNCHER_VISIBILITY";

NSString *ACTION_SOURCE_APP = @"ACTION_SOURCE_APP";
NSString *ACTION_SOURCE_SDK = @"ACTION_SOURCE_SDK";
NSString *NOTIFICATION_CLICKED = @"NOTIFICATION_CLICKED";


bool handleURI = YES;

Expand All @@ -93,16 +97,17 @@ - (void)init:(CDVInvokedUrlCommand*)command{
NSString* appKey = [command.arguments objectAtIndex:0];
NSString* accessKey = [command.arguments objectAtIndex:1];
[ZohoSalesIQ setPlatformWithPlatform:@"Cordova"];
[ZohoSalesIQ initWithAppKey:appKey accessKey:accessKey completion:^(BOOL success) {
[ZohoSalesIQ initWithAppKey:appKey accessKey:accessKey authProvider:NULL completion:^(id<SIQError> _Nullable error) {
CDVPluginResult* pluginResult = nil;
if(success == true){
if (error == nil) {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES];
[[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId];
}else{
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsBool:NO];
[[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId];
}
}];

if(actionDictionary == nil){
actionDictionary = [[NSMutableDictionary<NSString *, SIQActionHandler *> alloc] init];
}
Expand Down Expand Up @@ -926,6 +931,67 @@ - (void)dismissUI:(CDVInvokedUrlCommand*)command{
[ZohoSalesIQ dismissUI];
}

- (void)hideQueueTime:(CDVInvokedUrlCommand*)command {
BOOL hide = [[command.arguments objectAtIndex:0] boolValue];
[[ZohoSalesIQ Chat] hideQueueTime:hide];
}


- (void)registerLocalizationFile:(CDVInvokedUrlCommand*)command {
NSString *fileName = [command.arguments objectAtIndex:0];
if(fileName != nil){
[ZohoSalesIQ registerLocalizationFileWith:fileName];
}
}

- (void)setNotificationActionSource:(CDVInvokedUrlCommand*)command {
NSString *action = [command.arguments objectAtIndex:0];
if([action isEqual: ACTION_SOURCE_APP]){
[[ZohoSalesIQ Notification] setActionWith: ActionSourceApp];
}else if ([action isEqual: ACTION_SOURCE_SDK]){
[[ZohoSalesIQ Notification] setActionWith: ActionSourceSdk];
}
}

- (void)isSDKMessage:(CDVInvokedUrlCommand*)command {
NSDictionary *payload = [command.arguments objectAtIndex:0];
CDVPluginResult* pluginResult = nil;
if ([ZohoSalesIQ isMobilistenNotification: payload]) {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:YES];
[[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:NO];
[[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId];
}
}

- (void)getNotificationPayload:(CDVInvokedUrlCommand*)command {
NSDictionary *payload = [command.arguments objectAtIndex:0];
[[ZohoSalesIQ Notification] getPayload:payload completion:^(SalesIQNotificationPayload * _Nullable completionObject) {
NSMutableDictionary *resultMap = [NSMutableDictionary dictionary];
CDVPluginResult* pluginResult = nil;
if (completionObject != nil) {
if ([completionObject isKindOfClass:[SalesIQChatNotificationPayload class]]) {
SalesIQChatNotificationPayload *chatPayload = (SalesIQChatNotificationPayload *)completionObject;
resultMap[@"type"] = @"chat";
resultMap[@"payload"] = [chatPayload toDictionary];
} else if ([completionObject isKindOfClass:[SalesIQEndChatNotificationPayload class]]) {
SalesIQEndChatNotificationPayload *endChatPayload = (SalesIQEndChatNotificationPayload *)completionObject;
resultMap[@"type"] = @"endChatDetails";
resultMap[@"payload"] = [endChatPayload toDictionary];
} else if ([completionObject isKindOfClass:[SalesIQVisitorHistoryNotificationPayload class]]) {
SalesIQVisitorHistoryNotificationPayload *visitorHistoryPayload = (SalesIQVisitorHistoryNotificationPayload *)completionObject;
resultMap[@"type"] = @"visitorHistory";
resultMap[@"payload"] = [visitorHistoryPayload toDictionary];
}
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:resultMap];
[[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:resultMap];
[[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId];
}
}];
}

//MARK:- KNOWLEGEBASE APIs
- (void)isKnowledgeBaseEnabled: (CDVInvokedUrlCommand*)command {
Expand Down Expand Up @@ -1104,6 +1170,13 @@ - (void)showChatFeedbackUpTo:(CDVInvokedUrlCommand*)command{
[[ZohoSalesIQ Chat] showFeedbackWithUptoDuration: duration];
}

- (void)isChatEnabled:(CDVInvokedUrlCommand*)command{
BOOL chatEnabled = [[ZohoSalesIQ Chat] isEnabled];
CDVPluginResult* pluginResult = nil;
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:chatEnabled];
[[self commandDelegate] sendPluginResult:pluginResult callbackId:command.callbackId];
}

//MARK:- Launcher APIs
- (void)setLauncherVisibilityMode:(CDVInvokedUrlCommand*)command{
NSString *mode = [command.arguments objectAtIndex:0];
Expand Down Expand Up @@ -1918,4 +1991,28 @@ - (void)handleCustomLauncherVisibility:(BOOL)visible {
[self sendEvent:HANDLE_CUSTOM_LAUNCHER_VISIBILITY body: visibleValue];
}

- (void)handleNotificationActionWithPayload:(NSDictionary<NSString *,id> *)payload {
[[ZohoSalesIQ Notification] getPayload: payload completion:^(SalesIQNotificationPayload * _Nullable completionObject) {
NSMutableDictionary *resultMap = [NSMutableDictionary dictionary];
if (completionObject != nil) {
if ([completionObject isKindOfClass:[SalesIQChatNotificationPayload class]]) {
SalesIQChatNotificationPayload *chatPayload = (SalesIQChatNotificationPayload *)completionObject;
resultMap[@"type"] = @"chat";
resultMap[@"payload"] = [chatPayload toDictionary];
} else if ([completionObject isKindOfClass:[SalesIQEndChatNotificationPayload class]]) {
SalesIQEndChatNotificationPayload *endChatPayload = (SalesIQEndChatNotificationPayload *)completionObject;
resultMap[@"type"] = @"endChatDetails";
resultMap[@"payload"] = [endChatPayload toDictionary];
} else if ([completionObject isKindOfClass:[SalesIQVisitorHistoryNotificationPayload class]]) {
SalesIQVisitorHistoryNotificationPayload *visitorHistoryPayload = (SalesIQVisitorHistoryNotificationPayload *)completionObject;
resultMap[@"type"] = @"visitorHistory";
resultMap[@"payload"] = [visitorHistoryPayload toDictionary];
}
} else {
NSLog(@"Completion object is nil");
}
[self sendEvent:NOTIFICATION_CLICKED body: resultMap];
}];
}

@end
55 changes: 41 additions & 14 deletions www/ZohoSalesIQ.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ 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
};

exports.Resource = {
ARTICLES: "RESOURCE_ARTICLES" // No I18N
}

exports.ActionSource = {
APP: "ACTION_SOURCE_APP",// No I18N
SDK: "ACTION_SOURCE_SDK",// No I18N
};

exports.Launcher = {
STATIC_MODE: 1,
Expand Down Expand Up @@ -64,18 +69,18 @@ exports.Launcher = {
enableDragToDismiss: function (enable) {
exec(null, null, serviceName, 'enableLauncherDragToDismiss', [enable]); // No I18N
}
}
};

exports.Event = {
OPEN_URL: "EVENT_OPEN_URL",
COMPLETE_CHAT_ACTION: "EVENT_COMPLETE_CHAT_ACTION"
}
};

exports.Tab = {
CONVERSATIONS: "TAB_CONVERSATIONS",
KNOWLEDGE_BASE: 'TAB_KNOWLEDGE_BASE', //No I18N
FAQ: 'TAB_FAQ' //No I18N
}
};

//Chat Types
exports.CHATTYPE = {
Expand Down Expand Up @@ -276,6 +281,10 @@ 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
};

//CONVERSATIONN APIS
exports.setConversationListTitle = function (title, success, error) {
Expand Down Expand Up @@ -365,19 +374,19 @@ exports.sendEventToJs = function (name, body) {

exports.sendEvent = function (name, ...values) {
exec(null, null, serviceName, 'sendEvent', [name, values]); // No I18N
}
};

exports.setLauncherPropertiesForAndroid = function (launcherPropertiesMap) {
exec(null, null, serviceName, 'setLauncherPropertiesForAndroid', [launcherPropertiesMap]); // No I18N
}
};

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) {
Expand All @@ -388,22 +397,40 @@ exports.Chat = {
},
showFeedback(upToDuration) {
exec(null, null, serviceName, 'showChatFeedbackUpTo', [upToDuration]); // No I18N
},
hideQueueTime(hide) {
exec(null, null, serviceName, 'hideQueueTime', [hide]);
},
isChatEnabled: function (success) {
exec(success, null, serviceName, 'isChatEnabled', []); // No I18N
}
}
};

exports.setTabOrder = function (...tabNames) {
exec(null, null, serviceName, 'setTabOrder', [tabNames]); // No I18N
}
};

exports.setThemeForAndroid = function (name) {
exec(null, null, serviceName, 'setThemeForAndroid', [name]); // No I18N
}
};


exports.Notification = {
setIconForAndroid: function (resourceName) {
exec(null, null, serviceName, 'setNotificationIconForAndroid', [resourceName]); // No I18N
}
},
setActionSource: function (actionSource) {
exec(null, null, serviceName, 'setNotificationActionSource', [actionSource]);
},
isSDKMessage: function (payload, success, error) {
exec(success, error, serviceName, 'isSDKMessage', [payload]); // No I18N
},
registerPush: function (token, isTestDevice) {
exec(null, null,serviceName, 'registerPush', [token, isTestDevice]); // No I18N
},
getPayload: function (payload, success, error) {
exec(success, error, serviceName, 'getNotificationPayload', [payload]); // No I18N
},
}

exports.Logger = {
Expand All @@ -427,7 +454,7 @@ exports.Logger = {
writeLogForiOS: function (log, level, success, error) {
exec(success, error, serviceName, 'writeLogForiOS', [log, level]); // No I18N
}
}
};

exports.KnowledgeBase = {
isEnabled: function (type, success, error) {
Expand Down Expand Up @@ -460,7 +487,7 @@ exports.KnowledgeBase = {
getCategories: function (type, departmentId = null, parentCategoryId = null, success, error) {
exec(success, error, serviceName, 'getKnowledgeBaseCategories',[type, departmentId, parentCategoryId]); // No I18N
}
}
};

function setPlatform(platform) {
exec(null, null, serviceName, 'setPlatform', [platform]);
Expand Down Expand Up @@ -495,4 +522,4 @@ function parseResult(input) {

window.addEventListener('orientationchange', function() {
exec(null, null, serviceName, 'refreshLauncher', []); // No I18N
});
});

0 comments on commit 45a1c2f

Please sign in to comment.