zego-zim-react-native
v2.18.2
Published
Zego ZIM SDK for React Native
Downloads
1,945
Readme
zego-zim-react-native
Getting started
$ npm install zego-zim-react-native --save
Mostly automatic installation
$ react-native link zego-zim-react-native
Usage
import ZIM from 'zego-zim-react-native';
// step1: create zim instance
var appID = 0;
var appSign = '';
ZIM.create({ appID, appSign });
var zim = ZIM.getInstance();
// step2: register callback function
zim.on('receivePeerMessage', function (zim, { messageList, fromConversationID }) {
console.log('receivePeerMessage', messageList, fromConversationID);
});
// step3: login
var userInfo = { userID: 'xxxx', userName: 'xxxx' };
zim.login(userInfo, '')
.then(function () {
// success
})
.catch(function (err) {
// failed
});
// step4: send peer text message
var toUserID = 'xxxx1';
var config = {
priority: 1 // priority,low:1, medium:2, high:3
};
var messageTextObj = { type: 1, message: 'TEXT CONTENT' };
zim.sendMessage(messageTextObj, toUserID, 0, config)
.then(function ({ message }) {
// success
})
.catch(function (err) {
// failed
});