0.2.2 • Published 3 years ago
@qiscus-integration/react-native-multichannel-widget v0.2.2
Dependency
- Minimum RN
>= 0.59
Installation
- Using npm:
npm i @qiscus-integration/react-native-multichannel-widget
USAGE
We use Hooks to synchronize data. To make it work we have to explicitly insert a mount point in your app like this:
// in your entry file like `App.js`
import {MultichannelWidgetProvider} from 'react-native-multichannel-widget';
// in your render function
return (
<MultichannelWidgetProvider> // <- use MultichannelWidgetProvider
<App />
</MultichannelWidgetProvider>
);
Initialization Widget
import Widget from 'react-native-multichannel-widget';
const widget = Widget();
widget.setup(AppId, {
title: 'selamat datang', //set custom title
subtitle: 'ready to serve', //set custom subtitle
avatar : '' //set custom avatar
});
Initiate Chat Room
widget.initiateChat('EMAIL', 'NAME', 'FCM_TOKEN')
.then(result => {
})
.catch(e => {
})
Use Header Component
<Header
height={56}
style={{
backgroundColor : 'orange'
}}
textColor = 'white'
/>
Props
height
(Integer) - Height of the Header, default is56
headerRight
(Object) - Extra props to be passed Component to the Right HeaderheaderLeft
(Object) - Extra props to be passed Component to the Left Headerstyle
(Object) - Extra props to be passed custom style headertextColor
(String) - Custom text color header
Use Chat Component
<MultichannelWidget
onSuccessGetRoom={room => {
}}
onDownload={onDownload}
onPressSendAttachment={onPressSendAttachment}
/>
Props
onSuccessGetRoom
(Function(room
)) - Callback when success get roomonPressSendAttachment
(Function) - Callback when button Send Attachment is tappedonDownload
(Function) - Callback when a download message attachment is tappedrenderSendAttachment
(Object) - Extra props to be custom Component button Send AttachmentrenderSendMessage
(Object) - Extra props to be custom Component button Send MessagerenderSendMessage
(Object) - Extra props to be custom Component button Send Messageplaceholder
(String) - Extra props to be custom placeholder, defaultType a message...
renderTickSent
(Object) - Extra props to be custom Component Tick SentrenderTickDelivered
(Object) - Extra props to be custom Component Tick DeliveredrenderTickRead
(Object) - Extra props to be custom Component Tick ReadrenderTickPending
(Object) - Extra props to be custom Component Tick Pending
Example App
Example folder contains an example app to demonstrate how to use this package.
Get Unread Message Count
widget.getUnreadCount(callback)
Remove current user
widget.clearUser()
Remove Notification
widget.removeNotification('FCM_TOKEN')