From 1b1227e223c35a534dba255d0b485f55bb67559a Mon Sep 17 00:00:00 2001 From: anbarasu-v Date: Tue, 1 Feb 2022 12:30:03 +0530 Subject: [PATCH] Release v4.2.6 Release v4.2.6 --- README.md | 2 +- android/build.gradle | 5 +++- .../reactlibrary/RNZohoSalesIQ.java | 23 +++++++++++++++++-- components/zohosalesiqJSWrapper.js | 7 ++++++ ios/RNZohoSalesIQ.m | 16 +++++++++---- ios/RNZohoSalesIQ.podspec | 2 +- package.json | 2 +- 7 files changed, 46 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 889077b..d37d119 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/react-native-sdk-installation.html) [![Version](https://img.shields.io/badge/version-4.2.5-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-4.2.6-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 diff --git a/android/build.gradle b/android/build.gradle index 8631ece..57dc873 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,6 +1,7 @@ buildscript { repositories { jcenter() + google() } dependencies { @@ -10,6 +11,7 @@ buildscript { apply plugin: 'com.android.library' + def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback } @@ -31,9 +33,10 @@ android { repositories { mavenCentral() + google() } dependencies { compile 'com.facebook.react:react-native:+' - implementation 'com.zoho.salesiq:mobilisten:4.2.2' + implementation 'com.zoho.salesiq:mobilisten:4.2.3' } diff --git a/android/src/main/java/com/zohosalesiq/reactlibrary/RNZohoSalesIQ.java b/android/src/main/java/com/zohosalesiq/reactlibrary/RNZohoSalesIQ.java index 6488b62..1c7fd29 100644 --- a/android/src/main/java/com/zohosalesiq/reactlibrary/RNZohoSalesIQ.java +++ b/android/src/main/java/com/zohosalesiq/reactlibrary/RNZohoSalesIQ.java @@ -24,6 +24,7 @@ import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.modules.core.DeviceEventManagerModule; import com.zoho.commons.OnInitCompleteListener; +import com.zoho.livechat.android.NotificationListener; import com.zoho.livechat.android.SIQDepartment; import com.zoho.livechat.android.SIQVisitor; import com.zoho.livechat.android.SIQVisitorLocation; @@ -87,6 +88,7 @@ public class RNZohoSalesIQ extends ReactContextBaseJavaModule { private static final String EVENT_PERFORM_CHATACTION = "EVENT_PERFORM_CHATACTION"; // No I18N private static final String EVENT_CUSTOMTRIGGER = "EVENT_CUSTOMTRIGGER"; // No I18N private static final String EVENT_CHAT_QUEUE_POSITION_CHANGED = "EVENT_CHAT_QUEUE_POSITION_CHANGED"; // No I18N + private static final String EVENT_CHAT_UNREAD_COUNT_CHANGED = "EVENT_CHAT_UNREAD_COUNT_CHANGED"; // No I18N private static final String TYPE_OPEN = "OPEN"; // No I18N private static final String TYPE_CONNECTED = "CONNECTED"; // No I18N @@ -133,6 +135,7 @@ public Map getConstants() { constants.put("PERFORM_CHATACTION", EVENT_PERFORM_CHATACTION); // No I18N constants.put("CUSTOMTRIGGER", EVENT_CUSTOMTRIGGER); // No I18N constants.put("CHAT_QUEUE_POSITION_CHANGED", EVENT_CHAT_QUEUE_POSITION_CHANGED); // No I18N + constants.put("CHAT_UNREAD_COUNT_CHANGED", EVENT_CHAT_UNREAD_COUNT_CHANGED); // No I18N constants.put("ARTICLE_LIKED", EVENT_ARTICLE_LIKED); // No I18N constants.put("ARTICLE_DISLIKED", EVENT_ARTICLE_DISLIKED); // No I18N @@ -422,6 +425,7 @@ public void run() { ZohoSalesIQ.Chat.setListener(new RNZohoSalesIQListener()); ZohoSalesIQ.FAQ.setListener(new RNZohoSalesIQListener()); ZohoSalesIQ.ChatActions.setListener(new RNZohoSalesIQListener()); + ZohoSalesIQ.Notification.setListener(new RNZohoSalesIQListener()); } }); } @@ -439,6 +443,7 @@ public void run() { ZohoSalesIQ.Chat.setListener(new RNZohoSalesIQListener()); ZohoSalesIQ.FAQ.setListener(new RNZohoSalesIQListener()); ZohoSalesIQ.ChatActions.setListener(new RNZohoSalesIQListener()); + ZohoSalesIQ.Notification.setListener(new RNZohoSalesIQListener()); } }); } @@ -961,6 +966,16 @@ public void run() { }); } + @ReactMethod + public void getChatUnreadCount(@NonNull final Callback callback){ + Handler handler = new Handler(Looper.getMainLooper()); + handler.post(new Runnable() { + public void run() { + callback.invoke(ZohoSalesIQ.Notification.getBadgeCount()); + } + }); + } + @ReactMethod public void addListener(String eventName) { // Keep: Required for RN built in Event Emitter Calls. @@ -1178,7 +1193,7 @@ public WritableMap getVisitorInfoObject(SIQVisitor siqVisitor) { return infoMap; } - public class RNZohoSalesIQListener implements SalesIQListener, SalesIQChatListener, SalesIQFAQListener, SalesIQActionListener { + public class RNZohoSalesIQListener implements SalesIQListener, SalesIQChatListener, SalesIQFAQListener, SalesIQActionListener, NotificationListener { @Override public void handleFeedback(VisitorChat visitorChat) { @@ -1304,8 +1319,12 @@ public void handleCustomAction(SalesIQCustomAction salesIQCustomAction, final Sa actionDetailsMap.putString("clientActionName", salesIQCustomAction.clientActionName); // No I18N actionsList.put(uuid.toString(), salesIQCustomActionListener); - eventEmitter(EVENT_PERFORM_CHATACTION, actionDetailsMap); } + + @Override + public void onBadgeChange(int count) { + eventEmitter(EVENT_CHAT_UNREAD_COUNT_CHANGED, count); + } } } diff --git a/components/zohosalesiqJSWrapper.js b/components/zohosalesiqJSWrapper.js index 7508f58..e598b09 100644 --- a/components/zohosalesiqJSWrapper.js +++ b/components/zohosalesiqJSWrapper.js @@ -25,6 +25,7 @@ module.exports = { EVENT_CHAT_ATTENDED : RNZohoSalesIQ.CHAT_ATTENDED, EVENT_CHAT_MISSED : RNZohoSalesIQ.CHAT_MISSED, EVENT_CHAT_QUEUE_POSITION_CHANGED : RNZohoSalesIQ.CHAT_QUEUE_POSITION_CHANGED, + EVENT_CHAT_UNREAD_COUNT_CHANGED : RNZohoSalesIQ.CHAT_UNREAD_COUNT_CHANGED, EVENT_FEEDBACK_RECEIVED : RNZohoSalesIQ.FEEDBACK_RECEIVED, EVENT_RATING_RECEIVED : RNZohoSalesIQ.RATING_RECEIVED, @@ -202,5 +203,11 @@ module.exports = { }, isMultipleOpenChatRestricted: function(callback){ RNZohoSalesIQ.isMultipleOpenChatRestricted(callback); + }, + isChatEnabled: function(callback){ + RNZohoSalesIQ.isChatEnabled(callback); + }, + getChatUnreadCount: function(callback){ + RNZohoSalesIQ.getChatUnreadCount(callback); } } diff --git a/ios/RNZohoSalesIQ.m b/ios/RNZohoSalesIQ.m index 0008ff9..f33978d 100644 --- a/ios/RNZohoSalesIQ.m +++ b/ios/RNZohoSalesIQ.m @@ -86,9 +86,9 @@ -(void)stopObserving { NSString *RATING_RECEIVED = @"RATING_RECEIVED"; NSString *CHAT_REOPENED = @"CHAT_REOPENED"; NSString *CHAT_QUEUE_POSITION_CHANGED = @"CHAT_QUEUE_POSITION_CHANGED"; +NSString *CHAT_UNREAD_COUNT_CHANGED = @"CHAT_UNREAD_COUNT_CHANGED"; NSString *PERFORM_CHATACTION = @"PERFORM_CHATACTION"; -NSString *UNREAD_COUNT_CHANGED = @"UNREAD_COUNT_CHANGED"; NSString *VISITOR_IPBLOCKED = @"VISITOR_IPBLOCKED"; NSString *CUSTOMTRIGGER = @"CUSTOMTRIGGER"; @@ -122,11 +122,11 @@ -(void)stopObserving { CHAT_OPENED, RATING_RECEIVED, CHAT_REOPENED, - UNREAD_COUNT_CHANGED, VISITOR_IPBLOCKED, PERFORM_CHATACTION, CUSTOMTRIGGER, - CHAT_QUEUE_POSITION_CHANGED]; + CHAT_QUEUE_POSITION_CHANGED, + CHAT_UNREAD_COUNT_CHANGED]; } - (NSDictionary *) constantsToExport { @@ -151,7 +151,7 @@ - (NSDictionary *) constantsToExport { @"CHAT_OPENED": CHAT_OPENED, @"RATING_RECEIVED": RATING_RECEIVED, @"CHAT_REOPENED": CHAT_REOPENED, - @"UNREAD_COUNT_CHANGED": UNREAD_COUNT_CHANGED, + @"CHAT_UNREAD_COUNT_CHANGED": CHAT_UNREAD_COUNT_CHANGED, @"VISITOR_IPBLOCKED": VISITOR_IPBLOCKED, @"TYPE_OPEN": TYPE_OPEN, @"TYPE_WAITING": TYPE_WAITING, @@ -788,6 +788,12 @@ + (void)handleNotificationAction: (NSDictionary *) info response:(NSString *) re callback(@[chatEnabled]); } +RCT_EXPORT_METHOD(getChatUnreadCount:(RCTResponseSenderBlock)callback) +{ + NSNumber *unreadCount = [NSNumber numberWithInteger: [[ZohoSalesIQ Chat] getUnreadMessageCount]]; + callback(@[unreadCount]); +} + //MARK:- CHAT GET LIST API RCT_EXPORT_METHOD(getChats:(RCTResponseSenderBlock)callback) { @@ -1108,7 +1114,7 @@ - (void)chatReopenedWithChat:(SIQVisitorChat * _Nullable)chat { - (void)unreadCountChanged:(NSInteger)count { if (hasListeners) - [self sendEventWithName:UNREAD_COUNT_CHANGED body: @(count)]; + [self sendEventWithName:CHAT_UNREAD_COUNT_CHANGED body: @(count)]; } - (void)visitorIPBlocked { diff --git a/ios/RNZohoSalesIQ.podspec b/ios/RNZohoSalesIQ.podspec index 965c58f..86857d7 100644 --- a/ios/RNZohoSalesIQ.podspec +++ b/ios/RNZohoSalesIQ.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "RNZohoSalesIQ" - s.version = "4.2.4" + s.version = "4.2.5" 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" diff --git a/package.json b/package.json index ef6a297..7f4f489 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-zohosalesiq-mobilisten", - "version": "4.2.5", + "version": "4.2.6", "description": "A React Native module for the ZohoSalesIQ Mobilisten SDK", "bugs": { "email": "support@zohosalesiq.com"