
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
react-native-freshchat-sdk-latest
Advanced tools
A React Native module that allows you to use the native Freshchat SDK
yarn add react-native-freshchat-sdk-latest
OR npm install react-native-freshchat-sdk-latest --save
react-native link
on you project root directoryios
folder in your projectPodfile
target 'ProjectName' do
pod 'FreshchatSDK', :path=> '../node_modules/react-native-freshchat-sdk-latest/ios/FreshchatSDK.podspec'
end
pod install
from ios directoryFollow how to manually link a library here https://facebook.github.io/react-native/docs/linking-libraries-ios.html#content
Add maven { url "https://jitpack.io” }
to you project level build.gradle as below
allprojects {
repositories {
.....
maven { url "https://jitpack.io" }
}
}
import {
Freshchat,
FreshchatConfig,
FaqOptions,
ConversationOptions,
FreshchatUser,
FreshchatMessage,
FreshchatNotificationConfig
} from 'react-native-freshchat-sdk-latest';
var freshchatConfig = new FreshchatConfig('YOUR_APP_ID', 'YOUR_APP_KEY');
Freshchat.init(freshchatConfig);
Freshchat.showFAQs();
var faqOptions = new FaqOptions();
faqOptions.tags = ["premium"];
faqOptions.filteredViewTitle = "Tags";
faqOptions.filterType = FaqOptions.FilterType.ARTICLE;
Freshchat.showFAQs(faqOptions);
Freshchat.showConversations();
var conversationOptions = new ConversationOptions();
conversationOptions.tags = ["premium"];
conversationOptions.filteredViewTitle = "Premium Support";
Freshchat.showConversations(conversationOptions);
Freshchat.resetUser();
Freshchat.getUnreadCountAsync((data) => {
console.log(data);
});
Freshchat.addEventListener(
Freshchat.EVENT_UNREAD_MESSAGE_COUNT_CHANGED,
() => {
console.log("onUnreadMessageCountChanged triggered");
Freshchat.getUnreadCountAsync((data) => {
var count = data.count;
var status = data.status;
if (status) {
console.log("Message count: " + count);
} else {
console.log("getUnreadCountAsync unsuccessful");
}
});
}
);
Freshchat.removeEventListeners(Freshchat.EVENT_UNREAD_MESSAGE_COUNT_CHANGED);
Freshchat.getUser((user) => {
console.log(user);
})
var freshchatUser = new FreshchatUser();
freshchatUser.firstName = "John";
freshchatUser.lastName = "Doe";
freshchatUser.email = "johndoe@dead.man";
freshchatUser.phoneCountryCode = "+91";
freshchatUser.phone = "1234234123";
Freshchat.setUser(freshchatUser, (error) => {
console.log(error);
});
var userPropertiesJson = {
"user_type": "Paid",
"plan": "Gold"
}
Freshchat.setUserProperties(userPropertiesJson, (error) => {
console.log(error);
});
Freshchat.getSDKVersionCode((data) => {
console.log(data);
});
var freshchatMessage = new FreshchatMessage();
freshchatMessage.tag = "video";
freshchatMessage.message = "text send message";
Freshchat.sendMessage(freshchatMessage);
Freshchat.dismissFreshchatViews();
Freshchat.identifyUser("EXTERNAL_ID", "RESTORE_ID", (error) => {
console.log(error);
});
Freshchat.addEventListener(
Freshchat.EVENT_USER_RESTORE_ID_GENERATED,
() => {
console.log("onRestoreIdUpdated triggered");
Freshchat.getUser((user) => {
var restoreId = user.restoreId;
var externalId = user.externalId;
console.log("externalId: " + externalId);
console.log("restoreId: " + restoreId);
})
}
);
Freshchat.removeEventListeners(Freshchat.EVENT_USER_RESTORE_ID_GENERATED);
var freshchatNotificationConfig = new FreshchatNotificationConfig();
freshchatNotificationConfig.priority = FreshchatNotificationConfig.NotificationPriority.PRIORITY_HIGH;
freshchatNotificationConfig.notificationSoundEnabled = false;
Freshchat.setNotificationConfig(freshchatNotificationConfig);
Freshchat.setPushRegistrationToken(token);
Freshchat.isFreshchatNotification(notification, (freshchatNotification) => {
if (freshchatNotification) {
Freshchat.handlePushNotification(notification);
} else {
// handle your app notification
}
})
In iOS, Application state should be sent as part of notification payload to effectively handle notification
isActive
field should be true
if Application state is active, false
otherwise.
isActive
parameter:NSMutableDictionary *mutableDict = [response.notification.request.content.userInfo mutableCopy];
BOOL isActive = [UIApplication sharedApplication].applicationState == UIApplicationStateActive;
[mutableDict setObject:@(isActive) forKey:@"isActive"];
Note: If this parameter is not set, Conversations screen will not open when app is inactive or in background. Instead In-App notification will be shown.
const notificationPayload = Freshchat.transformPushNotificationIOSPayloadToNativePayload(notification);
If you want to handle push notifications in Native layer. You can follow the below steps
import "FreshchatSDK.h"
[[FreshchatSDK sharedInstance]setPushRegistrationToken:deviceToken];
if ([[FreshchatSDK sharedInstance]isFreshchatNotification:userInfo]) {
[[FreshchatSDK sharedInstance]handlePushNotification:userInfo];
} else {
// handle your app notification
}
Freshchat.getInstance(context).setPushRegistrationToken(token);
if (Freshchat.isFreshchatNotification(message)) {
Freshchat.getInstance(getApplicationContext()).handleFcmMessage(message);
} else {
// handle your app notification
}
Add event listener for Freshchat.EVENT_USER_INTERACTED event. When user interacts with app, this event will be triggered.
Freshchat.addEventListener(
Freshchat.EVENT_USER_INTERACTED,
userInteractionHandler
);
iOS Specific configuration
In AppDelegate.h, Use RNFreshchatWindow
instead of UIWindow
, which extends UIWindow
#import "RNFreshchatSdk.h"
@property (nonatomic, strong) RNFreshchatWindow *window;
In AppDelegate.m,
RNFreshchatWindow
instead of UIWindow
applicationDidEnterBackground
and trigger FRESHCHAT_USER_INTERACTED
event as below
- (void)applicationDidEnterBackground:(UIApplication *)application {
[[NSNotificationCenter defaultCenter] postNotificationName:FRESHCHAT_USER_INTERACTED object:self];
}
To remove event listener, use the below code
Freshchat.removeEventListeners(Freshchat.EVENT_USER_INTERACTED);
restoreUserWithIdToken
with JWT token.setUserWithIdToken
with JWT token.getUserIdTokenStatus
return current status of the JWT tokengetFreshchatUserId
generate and return user aliasFreshchat.FRESHCHAT_EVENTS
event to listen to user interactions like SCREEN_TRANSITIONS and NEW_MESSAGE.JWT Token will be in any one of the below 5 states
Freshchat.restoreUserWithIdToken(jwt);
Freshchat.setUserWithIdToken(jwt);
Freshchat.getUserIdTokenStatus((data) => {
var status = data.user_id_token_status;
console.log('FRESHCHAT_EVENTS: state - ', status);
});
Freshchat.getFreshchatUserId((alias) => {
console.log('Alias - ', alias);
});
Adding Listener
Freshchat.addEventListener(
Freshchat.FRESHCHAT_EVENTS,
userActionsEventHandler
);
Handling when event triggered
const userActionsEventHandler = (actionData) => {
console.log("FRESHCHAT_EVENTS triggered");
var action = actionData.user_action;
Freshchat.getUserIdTokenStatus((data) => {
var status = data.user_id_token_status;
console.log('FRESHCHAT_EVENTS: action - ', action);
console.log('FRESHCHAT_EVENTS: state - ', status);
});
};
Adding listener
Freshchat.addEventListener(
Freshchat.EVENT_EXTERNAL_LINK_CLICKED,
openLinkHandler
);
Handling when event triggered
const openLinkHandler = (data) => {
console.log("link - ", data.url);
};
Freshchat.addEventListener(
Freshchat.FRESHCHAT_NOTIFICATION_CLICKED,
(data) => {
// if (canOpenSdkScreenDirectly) {
Freshchat.openFreshchatDeeplink(data.url);
// } else {
// save deeplink and open Freshchat screen when required
// }
}
);
When app is in killed state and SDK screen is opened directly due to notifications, activityToLaunchOnFinish
will be launched when user clicks back button from SDK screen.
Set overrideNotificationClickListener
to true
when you want to override notification click event in Android.
Configure FreshchatNotificationConfig as follows.
var freshchatNotificationConfig = new FreshchatNotificationConfig();
freshchatNotificationConfig.priority = FreshchatNotificationConfig.NotificationPriority.PRIORITY_HIGH;
freshchatNotificationConfig.notificationSoundEnabled = false;
freshchatNotificationConfig.activityToLaunchOnFinish = "com.demoapp.MainActivity";
freshchatNotificationConfig.overrideNotificationClickListener = true;
Freshchat.setNotificationConfig(freshchatNotificationConfig);
More instructions here: Freshchat for Android
More instructions here: Freshchat for iOS
FAQs
A React Native module that allows you to use the native Freshchat SDK
The npm package react-native-freshchat-sdk-latest receives a total of 23 weekly downloads. As such, react-native-freshchat-sdk-latest popularity was classified as not popular.
We found that react-native-freshchat-sdk-latest demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.