Skip to content

Commit

Permalink
Release v6.1.0
Browse files Browse the repository at this point in the history
Release v6.1.0
  • Loading branch information
yeskay-zohocorp committed Aug 28, 2023
1 parent 33e3fcf commit 6f351b4
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 57 deletions.
4 changes: 2 additions & 2 deletions 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/react-native-sdk-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-ReactNative/workflows/Mobilisten%20NPM%20CD/badge.svg)](https://github.com/zoho/SalesIQ-Mobilisten-ReactNative/actions)
[![SupportedLanguages](https://img.shields.io/badge/Platforms-iOS%20%7C%20%20Android-green.svg)](https://www.zoho.com/salesiq/help/developer-section/react-native-sdk-installation.html) [![Version](https://img.shields.io/badge/version-6.1.0-blue.svg)](https://mobilisten.io/) [![Mobilisten NPM CD](https://github.com/zoho/SalesIQ-Mobilisten-ReactNative/workflows/Mobilisten%20NPM%20CD/badge.svg)](https://github.com/zoho/SalesIQ-Mobilisten-ReactNative/actions)

# React Native module for SalesIQ Mobilisten SDK

Expand All @@ -10,7 +10,7 @@ Connect with customers at every step of their journey. Give them the best in-app
## Requirements
**iOS**: Minimum deployment target should be set to iOS 11.

**Android**: Android API level 16 and above is required.
**Android**: Android API level 21 and above is required.

## Installation
Follow the below steps given below to complete installation of **Mobilisten** in your React-Native app.
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ repositories {

dependencies {
implementation 'com.facebook.react:react-native:+'
implementation 'com.zoho.salesiq:mobilisten:5.1.0'
implementation 'com.zoho.salesiq:mobilisten:6.0.1'
}
150 changes: 98 additions & 52 deletions android/src/main/java/com/zohosalesiq/reactlibrary/RNZohoSalesIQ.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.app.Activity;
import android.app.Application;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
Expand All @@ -14,6 +13,7 @@
import android.util.Base64;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;

import com.facebook.react.bridge.Callback;
Expand Down Expand Up @@ -45,15 +45,17 @@
import com.zoho.livechat.android.listeners.DepartmentListener;
import com.zoho.livechat.android.listeners.FAQCategoryListener;
import com.zoho.livechat.android.listeners.FAQListener;
import com.zoho.livechat.android.listeners.OpenArticleListener;
import com.zoho.livechat.android.listeners.OperatorImageListener;
import com.zoho.livechat.android.listeners.SalesIQActionListener;
import com.zoho.livechat.android.listeners.SalesIQChatListener;
import com.zoho.livechat.android.listeners.SalesIQCustomActionListener;
import com.zoho.livechat.android.listeners.SalesIQFAQListener;
import com.zoho.livechat.android.listeners.SalesIQListener;
import com.zoho.livechat.android.models.SalesIQArticle;
import com.zoho.livechat.android.models.SalesIQArticleCategory;
import com.zoho.livechat.android.modules.knowledgebase.ui.entities.Resource;
import com.zoho.livechat.android.modules.knowledgebase.ui.listeners.OpenResourceListener;
import com.zoho.livechat.android.modules.knowledgebase.ui.listeners.ResourcesListener;
import com.zoho.livechat.android.modules.knowledgebase.ui.listeners.SalesIQKnowledgeBaseListener;
import com.zoho.livechat.android.operation.SalesIQApplicationManager;
import com.zoho.livechat.android.utils.LiveChatUtil;
import com.zoho.salesiqembed.ZohoSalesIQ;
Expand All @@ -63,6 +65,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.UUID;

Expand Down Expand Up @@ -136,7 +139,8 @@ public class RNZohoSalesIQ extends ReactContextBaseJavaModule {

enum Tab {
CONVERSATIONS("TAB_CONVERSATIONS"),
FAQ("TAB_FAQ");
@Deprecated FAQ("TAB_FAQ"),
KNOWLEDGE_BASE("TAB_KNOWLEDGE_BASE");

final String name;

Expand All @@ -162,6 +166,7 @@ public Map<String, Object> getConstants() {

constants.put("TAB_CONVERSATIONS", Tab.CONVERSATIONS.name); // No I18N
constants.put("TAB_FAQ", Tab.FAQ.name); // No I18N
constants.put("TAB_KNOWLEDGE_BASE", Tab.KNOWLEDGE_BASE.name); // No I18N

constants.put("SUPPORT_OPENED", EVENT_SUPPORT_OPENED); // No I18N
constants.put("SUPPORT_CLOSED", EVENT_SUPPORT_CLOSED); // No I18N
Expand Down Expand Up @@ -393,22 +398,18 @@ public void getArticlesWithCategoryID(
@NonNull final String categoryId,
@NonNull final Callback articlesCallback
) {
HANDLER.post(() -> ZohoSalesIQ.FAQ.getArticles(categoryId, new FAQListener() {
HANDLER.post(() -> ZohoSalesIQ.KnowledgeBase.getResources(ZohoSalesIQ.ResourceType.Articles, null, categoryId, null, new ResourcesListener() {
@Override
public void onSuccess(ArrayList<SalesIQArticle> articlesList) {
if (articlesList != null) {
WritableArray array = new WritableNativeArray();
for (int i = 0; i < articlesList.size(); i++) {
SalesIQArticle article = articlesList.get(i);
WritableMap articleMap = getArticleMapObject(article);
array.pushMap(articleMap);
}
articlesCallback.invoke(null, array);
public void onSuccess(@NonNull List<Resource> resources, boolean moreDataAvailable) {
WritableArray array = new WritableNativeArray();
for (int i = 0; i < resources.size(); i++) {
array.pushMap(getArticleMapObject(resources.get(i)));
}
articlesCallback.invoke(null, array);
}

@Override
public void onFailure(int code, String message) {
public void onFailure(int code, @Nullable String message) {
WritableMap errorMap = new WritableNativeMap();
errorMap.putInt("code", code); // No I18N
errorMap.putString("message", message); // No I18N
Expand Down Expand Up @@ -454,20 +455,22 @@ public void onFailure(int code, String message) {

@ReactMethod
public void openArticle(final String id, @NonNull final Callback articlesCallback) {
HANDLER.post(() -> ZohoSalesIQ.FAQ.openArticle(id, new OpenArticleListener() {
@Override
public void onSuccess() {
articlesCallback.invoke("null");
}
HANDLER.post(() -> ZohoSalesIQ.KnowledgeBase.open(ZohoSalesIQ.ResourceType.Articles, id,
new OpenResourceListener() {
@Override
public void onSuccess() {
articlesCallback.invoke("null");
}

@Override
public void onFailure(int code, String message) {
WritableMap errorMap = new WritableNativeMap();
errorMap.putInt("code", code); // No I18N
errorMap.putString("message", message); // No I18N
articlesCallback.invoke(errorMap);
}
}));
@Override
public void onFailure(int code, @Nullable String message) {
WritableMap errorMap = new WritableNativeMap();
errorMap.putInt("code", code); // No I18N
errorMap.putString("message", message); // No I18N
articlesCallback.invoke(errorMap);
}
}
));
}

@ReactMethod
Expand All @@ -478,7 +481,7 @@ public void init(final String appKey, final String accessKey) {
initSalesIQ(activity.getApplication(), activity, appKey, accessKey, null);
ZohoSalesIQ.setListener(new RNZohoSalesIQListener());
ZohoSalesIQ.Chat.setListener(new RNZohoSalesIQListener());
ZohoSalesIQ.FAQ.setListener(new RNZohoSalesIQListener());
ZohoSalesIQ.KnowledgeBase.setListener(new RNZohoSalesIQListener());
ZohoSalesIQ.ChatActions.setListener(new RNZohoSalesIQListener());
ZohoSalesIQ.Notification.setListener(new RNZohoSalesIQListener());
});
Expand All @@ -498,7 +501,7 @@ public void initWithCallback(
initCallback);
ZohoSalesIQ.setListener(new RNZohoSalesIQListener());
ZohoSalesIQ.Chat.setListener(new RNZohoSalesIQListener());
ZohoSalesIQ.FAQ.setListener(new RNZohoSalesIQListener());
ZohoSalesIQ.KnowledgeBase.setListener(new RNZohoSalesIQListener());
ZohoSalesIQ.ChatActions.setListener(new RNZohoSalesIQListener());
ZohoSalesIQ.Notification.setListener(new RNZohoSalesIQListener());
});
Expand Down Expand Up @@ -629,7 +632,7 @@ public void setConversationListTitle(final String title) {

@ReactMethod
public void setFAQVisibility(final Boolean visible) {
HANDLER.post(() -> ZohoSalesIQ.FAQ.setVisibility(visible));
HANDLER.post(() -> ZohoSalesIQ.KnowledgeBase.setVisibility(ZohoSalesIQ.ResourceType.Articles, visible));
}

@ReactMethod
Expand Down Expand Up @@ -860,7 +863,7 @@ public void setLauncherPropertiesForAndroid(final ReadableMap launcherProperties
ZohoSalesIQ.getApplicationManager() != null &&
ZohoSalesIQ.getApplicationManager().getApplication() != null
) {
int resourceId = getResourceId(launcherPropertiesMap.getString("icon"));
int resourceId = getDrawableResourceId(launcherPropertiesMap.getString("icon"));
Drawable drawable =
AppCompatResources.getDrawable(ZohoSalesIQ.getApplicationManager().getApplication(), resourceId);
if (resourceId > 0) {
Expand Down Expand Up @@ -939,11 +942,11 @@ public void onInitError() {
initCallback.invoke(false);
}
}
});
});
if (activity != null && ZohoSalesIQ.getApplicationManager() != null) {
ZohoSalesIQ.getApplicationManager().setCurrentActivity(activity);
ZohoSalesIQ.getApplicationManager().setAppActivity(activity);
}
}
}
}

Expand Down Expand Up @@ -979,7 +982,7 @@ private ConversationType getFilterName(String filter) {
}

public WritableMap getChatMapObject(VisitorChat chat) {
WritableMap visitorMap = new WritableNativeMap();
WritableMap visitorMap = new WritableNativeMap();
visitorMap.putString("id", chat.getChatID()); // No I18N
visitorMap.putInt("unreadCount", chat.getUnreadCount()); // No I18N
visitorMap.putBoolean("isBotAttender", chat.isBotAttender()); // No I18N
Expand Down Expand Up @@ -1064,6 +1067,28 @@ public WritableMap getChatMapObject(VisitorChat chat) {
return visitorMap;
}

public WritableMap getArticleMapObject(Resource resource) {
WritableMap articleMap = new WritableNativeMap();
if (resource != null) {
articleMap.putString("id", resource.getId()); // No I18N
articleMap.putString("name", resource.getTitle()); // No I18N
if (resource.getStats() != null) {
articleMap.putInt("likeCount", resource.getStats().getLiked()); // No I18N
articleMap.putInt("dislikeCount", resource.getStats().getDisliked()); // No I18N
articleMap.putInt("viewCount", resource.getStats().getViewed()); // No I18N
}
if (resource.getCategory() != null) {
if (resource.getCategory().getId() != null) {
articleMap.putString("categoryID", resource.getCategory().getId()); // No I18N
}
if (resource.getCategory().getName() != null) {
articleMap.putString("categoryName", resource.getCategory().getName()); // No I18N
}
}
}
return articleMap;
}

public WritableMap getArticleMapObject(SalesIQArticle article) {
WritableMap articleMap = new WritableNativeMap();
articleMap.putString("id", article.getId()); // No I18N
Expand Down Expand Up @@ -1145,8 +1170,7 @@ public WritableMap getVisitorInfoObject(SIQVisitor siqVisitor) {
return infoMap;
}

public class RNZohoSalesIQListener implements SalesIQListener, SalesIQChatListener,
SalesIQFAQListener, SalesIQActionListener, NotificationListener {
public class RNZohoSalesIQListener implements SalesIQListener, SalesIQChatListener, SalesIQKnowledgeBaseListener, SalesIQActionListener, NotificationListener {

@Override
public void handleFeedback(VisitorChat visitorChat) {
Expand Down Expand Up @@ -1177,23 +1201,23 @@ public void handleOperatorsOffline() {
}

@Override
public void handleArticleOpened(String id) {
eventEmitter(EVENT_ARTICLE_OPENED, id);
public void handleResourceOpened(@NonNull ZohoSalesIQ.ResourceType resourceType, @Nullable Resource resource) {
eventEmitter(EVENT_ARTICLE_OPENED, resource != null ? resource.getId() : null);
}

@Override
public void handleArticleClosed(String id) {
eventEmitter(EVENT_ARTICLE_CLOSED, id);
public void handleResourceClosed(@NonNull ZohoSalesIQ.ResourceType resourceType, @Nullable Resource resource) {
eventEmitter(EVENT_ARTICLE_CLOSED, resource != null ? resource.getId() : null);
}

@Override
public void handleArticleLiked(String id) {
eventEmitter(EVENT_ARTICLE_LIKED, id);
public void handleResourceLiked(@NonNull ZohoSalesIQ.ResourceType resourceType, @Nullable Resource resource) {
eventEmitter(EVENT_ARTICLE_LIKED, resource != null ? resource.getId() : null);
}

@Override
public void handleArticleDisliked(String id) {
eventEmitter(EVENT_ARTICLE_DISLIKED, id);
public void handleResourceDisliked(@NonNull ZohoSalesIQ.ResourceType resourceType, @Nullable Resource resource) {
eventEmitter(EVENT_ARTICLE_DISLIKED, resource != null ? resource.getId() : null);
}

@Override
Expand Down Expand Up @@ -1231,7 +1255,7 @@ public void handleTrigger(String triggerName, SIQVisitor visitor) {
}

@Override
public void handleBotTrigger() {
public void handleBotTrigger() {
eventEmitter(EVENT_BOT_TRIGGER, null);
}

Expand Down Expand Up @@ -1345,15 +1369,16 @@ public void shouldOpenUrl(final boolean value) {

@ReactMethod
public void setTabOrder(final ReadableArray tabNames) {
int minimumTabOrdersSize = Math.min(tabNames.size(), ZohoSalesIQ.Tab.values().length);
/** @apiNote Please remove the -1 below when the {@link ZohoSalesIQ.Tab.FAQ} is removed */
int minimumTabOrdersSize = Math.min(tabNames.size(), ZohoSalesIQ.Tab.values().length - 1);
ZohoSalesIQ.Tab[] tabOrder = new ZohoSalesIQ.Tab[minimumTabOrdersSize];
int insertIndex = 0;
for (int index = 0; index < minimumTabOrdersSize; index++) {
String tabName = tabNames.getString(index);
if (Tab.CONVERSATIONS.name.equals(tabName)) {
tabOrder[insertIndex++] = ZohoSalesIQ.Tab.Conversations;
} else if (Tab.FAQ.name.equals(tabName)) {
tabOrder[insertIndex++] = ZohoSalesIQ.Tab.FAQ;
} else if (Tab.FAQ.name.equals(tabName) || Tab.KNOWLEDGE_BASE.name.equals(tabName)) {
tabOrder[insertIndex++] = ZohoSalesIQ.Tab.KnowledgeBase;
}
}
ZohoSalesIQ.setTabOrder(tabOrder);
Expand All @@ -1366,16 +1391,37 @@ public void printDebugLogsForAndroid(final Boolean value) {

@ReactMethod
void setNotificationIconForAndroid(final String drawableName) {
int resourceId = getResourceId(drawableName);
int resourceId = getDrawableResourceId(drawableName);
if (resourceId > 0) {
ZohoSalesIQ.Notification.setIcon(resourceId);
}
}

private int getResourceId(String drawableName) {
@ReactMethod
void setThemeForAndroid(final String name) {
int resourceId = getStyleResourceId(name);
if (resourceId > 0) {
ZohoSalesIQ.setTheme(resourceId);
}
}


private int getStyleResourceId(String id) {
SalesIQApplicationManager salesIQApplicationManager = ZohoSalesIQ.getApplicationManager();
int resourceId = 0;
if (salesIQApplicationManager != null && salesIQApplicationManager.getApplication() != null) {
resourceId = salesIQApplicationManager.getApplication().getResources().getIdentifier(
id, "style", // No I18N
ZohoSalesIQ.getApplicationManager().getApplication().getPackageName());

}
return resourceId;
}

private int getDrawableResourceId(String drawableName) {
SalesIQApplicationManager salesIQApplicationManager = ZohoSalesIQ.getApplicationManager();
int resourceId = 0;
if (salesIQApplicationManager != null) {
if (salesIQApplicationManager != null && salesIQApplicationManager.getApplication() != null) {
resourceId = salesIQApplicationManager.getApplication().getResources().getIdentifier(
drawableName, "drawable", // No I18N
ZohoSalesIQ.getApplicationManager().getApplication().getPackageName());
Expand Down
3 changes: 3 additions & 0 deletions components/zohosalesiqJSWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ module.exports = {
printDebugLogsForAndroid: function (value) {
RNZohoSalesIQ.printDebugLogsForAndroid(value)
},
setThemeForAndroid: function (value) {
RNZohoSalesIQ.setThemeForAndroid(value)
},

Chat: {
shouldOpenUrl: function (value) {
Expand Down
4 changes: 4 additions & 0 deletions ios/RNZohoSalesIQ.m
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,10 @@ + (void)handleNotificationAction: (NSDictionary *) info response:(NSString *) re
RCT_EXPORT_METHOD(setThemeColorforAndroid: (NSString *)attribute color_code:(NSString *)color_code){
// No Implementation
}

RCT_EXPORT_METHOD(setThemeForAndroid: (NSString *)attribute){
// No Implementation
}
RCT_EXPORT_METHOD(setThemeColorforiOS: (NSString *)color_code){
unsigned rgbValue = 0;
NSScanner *scanner = [NSScanner scannerWithString:color_code];
Expand Down
2 changes: 1 addition & 1 deletion ios/RNZohoSalesIQ.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "RNZohoSalesIQ"
s.version = "6.0.0"
s.version = "6.0.1"
s.summary = "A React-Native module for the SalesIQ Mobilisten SDK"
s.description = "A React-Native module for the SalesIQ Mobilisten SDK"
s.homepage = "https://zoho.com"
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": "react-native-zohosalesiq-mobilisten",
"version": "6.0.0",
"version": "6.1.0",
"description": "A React Native module for the ZohoSalesIQ Mobilisten SDK",
"bugs": {
"email": "[email protected]"
Expand Down

0 comments on commit 6f351b4

Please sign in to comment.