Skip to content

Commit

Permalink
Release v4.2.13
Browse files Browse the repository at this point in the history
Release v4.2.13
  • Loading branch information
valliammai-sv committed Oct 18, 2022
1 parent a8b3801 commit 07ae121
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 82 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-4.2.12-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.13-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 @@ -8,7 +8,7 @@ Connect with customers at every step of their journey. Give them the best in-app
[**Mobilisten**](https://mobilisten.io/) is a support chat SDK that comes with a set of highly configurable APIs to suit your needs. Get started by generating an `App` and `Access` keys for your bundle ID from the SalesIQ console.

## Requirements
**iOS**: Minimum deployment target should be set to iOS 10.
**iOS**: Minimum deployment target should be set to iOS 11.

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

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ repositories {

dependencies {
implementation 'com.facebook.react:react-native:+'
implementation 'com.zoho.salesiq:mobilisten:4.2.9'
implementation 'com.zoho.salesiq:mobilisten:4.3.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
import com.zoho.salesiqembed.ZohoSalesIQ;
import com.zoho.commons.LauncherProperties;
import com.zoho.commons.LauncherModes;
import android.util.DisplayMetrics;
import android.graphics.Canvas;
import com.zoho.livechat.android.operation.SalesIQApplicationManager;

import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
Expand Down Expand Up @@ -108,9 +108,6 @@ public class RNZohoSalesIQ extends ReactContextBaseJavaModule {
private static final int LAUNCHER_MODE_STATIC = 1;
private static final int LAUNCHER_MODE_FLOATING = 2;

private static LauncherProperties fabLauncherProperties = null;
private static Boolean isLauncherInRightSide;

private static Hashtable<String, SalesIQCustomActionListener> actionsList = new Hashtable<>();

private static final Handler HANDLER = new Handler(Looper.getMainLooper());
Expand Down Expand Up @@ -399,8 +396,8 @@ public void onSuccess(ArrayList<SalesIQArticleCategory> categoryList) {
SalesIQArticleCategory category = categoryList.get(i);

WritableMap categoryMap = new WritableNativeMap();
categoryMap.putString("id", category.getCategoryid()); // No I18N
categoryMap.putString("name", category.getCategoryname()); // No I18N
categoryMap.putString("id", category.getCategoryId()); // No I18N
categoryMap.putString("name", category.getCategoryName()); // No I18N
categoryMap.putInt("articleCount", category.getCount()); // No I18N

array.pushMap(categoryMap);
Expand Down Expand Up @@ -955,68 +952,39 @@ public void run() {
});
}

private DisplayMetrics getDisplayMetrics() {
Activity activity = getCurrentActivity();
DisplayMetrics displayMetrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
return displayMetrics;
}

@ReactMethod
public void setLauncherPropertiesForAndroid(final ReadableMap launcherPropertiesMap) {
HANDLER.post(new Runnable() {
public void run() {
DisplayMetrics displayMetrics = getDisplayMetrics();
int screenHeight = displayMetrics.heightPixels;
int screenWidth = displayMetrics.widthPixels;
float seventyEightDpInPixel = 78 * displayMetrics.density;
int x = screenWidth - (int) seventyEightDpInPixel, y = screenHeight - (int) seventyEightDpInPixel;
if (launcherPropertiesMap.hasKey("x")){
x = launcherPropertiesMap.getInt("x");
}
if (launcherPropertiesMap.hasKey("y")){
y = launcherPropertiesMap.getInt("y");
}

if (x >= (screenWidth/2)) {
isLauncherInRightSide = true;
} else {
isLauncherInRightSide = false;
}

int mode = LauncherModes.STATIC;
public void run() {
int mode = LauncherModes.FLOATING;
if (launcherPropertiesMap.hasKey("mode")){
mode = launcherPropertiesMap.getInt("mode");
}
LauncherProperties launcherProperties = new LauncherProperties(mode);
launcherProperties.setX(x);
launcherProperties.setY(y <= screenHeight ? y : screenHeight);
fabLauncherProperties = launcherProperties;
LauncherProperties launcherProperties = new LauncherProperties(mode);
if (launcherPropertiesMap.hasKey("x")) {
int x = launcherPropertiesMap.getInt("x");
if (x > 0) {
launcherProperties.setX(x);
}
}
if (launcherPropertiesMap.hasKey("y")) {
int y = launcherPropertiesMap.getInt("y");
if (y > 0) {
launcherProperties.setY(y);
}
}
ZohoSalesIQ.setLauncherProperties(launcherProperties);
}
});
}

@ReactMethod
public static void refreshLauncherPropertiesForAndroid(final int screenWidth, final int screenHeight) {
public static void refreshLauncherPropertiesForAndroid() {
HANDLER.post(new Runnable() {
public void run() {
if (fabLauncherProperties != null && isLauncherInRightSide != null) {
if (isLauncherInRightSide) {
if (fabLauncherProperties.getX() < (screenWidth/2)) {
fabLauncherProperties.setX(screenWidth/2);
}
} else {
fabLauncherProperties.setX((screenWidth/2) - 1);
}
float y = fabLauncherProperties.getY();
double heightInPoints = (y / screenWidth);
y = (int) (screenHeight * heightInPoints);
fabLauncherProperties.setY((int) y);
ZohoSalesIQ.setLauncherProperties(fabLauncherProperties);
} else {
fabLauncherProperties = new LauncherProperties(LauncherModes.STATIC);
ZohoSalesIQ.setLauncherProperties(fabLauncherProperties);
public void run() {
SalesIQApplicationManager salesIQApplicationManager = ZohoSalesIQ.getApplicationManager();
if (salesIQApplicationManager != null && salesIQApplicationManager.canShowBubble(salesIQApplicationManager.getCurrentActivity())) {
salesIQApplicationManager.showChatBubble(salesIQApplicationManager.getCurrentActivity());
}
}
});
Expand All @@ -1040,7 +1008,7 @@ public static void handleNotification(final Application application, final Map e
HANDLER.post(new Runnable() {
public void run() {
initSalesIQ(application, null, appKey, accessKey, null);
ZohoSalesIQ.Notification.handle(application, extras, 0);
ZohoSalesIQ.Notification.handle(application, extras);
}
});
}
Expand Down Expand Up @@ -1165,8 +1133,8 @@ public WritableMap getArticleMapObject(SalesIQArticle article) {
articleMap.putInt("likeCount", article.getLiked()); // No I18N
articleMap.putInt("dislikeCount", article.getDisliked()); // No I18N
articleMap.putInt("viewCount", article.getViewed()); // No I18N
if (article.getCategory_id() != null) {
articleMap.putString("categoryID", article.getCategory_id()); // No I18N
if (article.getCategoryId() != null) {
articleMap.putString("categoryID", article.getCategoryId()); // No I18N
}
if (article.getCategoryName() != null) {
articleMap.putString("categoryName", article.getCategoryName()); // No I18N
Expand Down Expand Up @@ -1371,4 +1339,9 @@ public void onBadgeChange(int count) {
eventEmitter(EVENT_CHAT_UNREAD_COUNT_CHANGED, count);
}
}

@ReactMethod
public void printDebugLogsForAndroid(final Boolean value) {
ZohoSalesIQ.printDebugLogs(value);
}
}
12 changes: 6 additions & 6 deletions components/zohosalesiqJSWrapper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {NativeModules, Dimensions, PixelRatio} = require('react-native'); //No I18N
const {NativeModules, Dimensions} = require('react-native'); //No I18N
const {RNZohoSalesIQ} = NativeModules;
import {NativeEventEmitter} from 'react-native'; //No I18N
const emitter = new NativeEventEmitter(RNZohoSalesIQ);
Expand Down Expand Up @@ -215,14 +215,14 @@ module.exports = {
},
setLauncherPropertiesForAndroid: function(launcherPropertiesMap){
RNZohoSalesIQ.setLauncherPropertiesForAndroid(launcherPropertiesMap);
},
printDebugLogsForAndroid: function(value) {
RNZohoSalesIQ.printDebugLogsForAndroid(value)
}
}

if (Platform.OS === 'android') {
var devicePixelRatio = PixelRatio.get();
Dimensions.addEventListener('change', ({window:{width,height}})=> {
var windowWidth = Dimensions.get('window').width;
var windowHeight = Dimensions.get('window').height;
RNZohoSalesIQ.refreshLauncherPropertiesForAndroid(windowWidth * devicePixelRatio, windowHeight * devicePixelRatio);//width, height);
Dimensions.addEventListener('change', ({window:{width,height}})=> {
RNZohoSalesIQ.refreshLauncherPropertiesForAndroid();
});
}
40 changes: 29 additions & 11 deletions ios/RNZohoSalesIQ.m
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,6 @@ + (NSMutableDictionary *)getChatObject: (SIQVisitorChat*) chat

[chatDict setObject: [NSNumber numberWithBool: [chat isBotAttender]] forKey: @"isBotAttender"];

if([chat lastMessage] != nil){
[chatDict setObject: [chat lastMessage] forKey: @"lastMessage"];
}
if([chat lastMessageSender] != nil){
[chatDict setObject: [chat lastMessageSender] forKey: @"lastMessageSender"];
}
if([chat question] != nil){
[chatDict setObject: [chat question] forKey: @"question"];
}
Expand Down Expand Up @@ -454,10 +448,31 @@ + (NSMutableDictionary *)getChatObject: (SIQVisitorChat*) chat
[chatDict setObject: TYPE_CLOSED forKey: @"status"];
}

if([chat lastMessageTime] != nil){
NSDate *messageTime = [chat lastMessageTime];
int time = (int)[messageTime timeIntervalSince1970];
[chatDict setObject: @(time) forKey: @"lastMessageTime"];
if ([chat lastMessage] != nil){
if ([[chat lastMessage] file] != nil){
NSString *fileContent = [[[chat lastMessage] file] contentType];
NSString *comment = [[[chat lastMessage] file] comment];

if (fileContent != nil){
if (comment != nil){
[chatDict setObject:[NSString stringWithFormat:@"%@:%@",fileContent,comment] forKey: @"lastMessage"];
}else{
[chatDict setObject:fileContent forKey: @"lastMessage"];
}
}
} else if ([[chat lastMessage] text] != nil){
[chatDict setObject: [[chat lastMessage] text] forKey: @"lastMessage"];
}
NSString *sender = [[chat lastMessage] sender];
if( sender != nil){
[chatDict setObject: sender forKey: @"lastMessageSender"];
}

NSDate *messageTime = [[chat lastMessage] time];
if (messageTime != nil){
int time = (int)[messageTime timeIntervalSince1970];
[chatDict setObject: @(time) forKey: @"lastMessageTime"];
}
}

[chatDict setObject: @([chat unreadCount]) forKey: @"unreadCount"];
Expand Down Expand Up @@ -646,6 +661,9 @@ + (void)handleNotificationAction: (NSDictionary *) info response:(NSString *) re
}
RCT_EXPORT_METHOD(syncThemeWithOsForAndroid: (BOOL)sync){

}
RCT_EXPORT_METHOD(printDebugLogsForAndroid: (BOOL)sync){

}
RCT_EXPORT_METHOD(showOperatorImageInLauncher: (BOOL)show){
[[ZohoSalesIQ Chat] setVisibility:ChatComponentAttenderImageOnLauncher visible:show];
Expand Down Expand Up @@ -909,7 +927,7 @@ + (void)handleNotificationAction: (NSDictionary *) info response:(NSString *) re
//MARK:- GET CATEGORIES LIST API
RCT_EXPORT_METHOD(getCategories:(RCTResponseSenderBlock)callback)
{
[[ZohoSalesIQ FAQ] getCategories:^(NSError * _Nullable error, NSArray<SIQFAQCategory *> * _Nullable categories) {
[[ZohoSalesIQ FAQ] getCategoriesWithDepartmentIDS:nil :^(NSError * _Nullable error, NSArray<SIQFAQCategory *> * _Nullable categories) {
if(error != nil){
NSMutableDictionary *errorDictionary = [RNZohoSalesIQ getErrorObject:error];
callback(@[errorDictionary, @""]);
Expand Down
5 changes: 2 additions & 3 deletions ios/RNZohoSalesIQ.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

Pod::Spec.new do |s|
s.name = "RNZohoSalesIQ"
s.version = "4.2.8"
s.version = "4.2.9"
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 All @@ -26,7 +25,7 @@ Pod::Spec.new do |s|
LICENSE
}
s.author = { "Rishabh Raghunath" => "[email protected]" }
s.platform = :ios, "10.0"
s.platform = :ios, "11.0"
s.source = { :git => "https://github.com/zoho/SalesIQ-Mobilisten-iOS", :tag => "v#{s.version}" }
s.source_files = "*.{h,m}"
s.requires_arc = true
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": "4.2.12",
"version": "4.2.13",
"description": "A React Native module for the ZohoSalesIQ Mobilisten SDK",
"bugs": {
"email": "[email protected]"
Expand Down

0 comments on commit 07ae121

Please sign in to comment.