@applozic/core-sdk
v1.4.0
Published
Applozic Core SDK
Downloads
30
Readme
Applozic Core JavaScript SDK
Installation
$ npm i @applozic/core-sdk
Initialize
1. Using npm import
import ApplozicClient from '@applozic/core-sdk';
const applozicClient = new ApplozicClient('YOUR-APPLOZIC-APP-ID', {
events: {
onMessageReceived: ({ message }) => {
console.log('onMessageReceived', { message });
},
onMessageDelivered: (contactId, messageKey) => {
console.log('onMessageDelivered', { message });
},
onMessageRead: (contactId, messageKey) => {
console.log('onMessageRead', { contactId, messageKey });
},
onMessageSent: ({ message }) => {
console.log('onMessageSent', { message });
},
onMessageSentUpdate: message => {
console.log('onMessageSentUpdate', { sentMessageUpdate: message });
},
onMessageDeleted: (contactId, messageKey) => {
console.log('onMessageDeleted', { contactId, messageKey });
},
onConversationRead: userId => {
console.log('onConversationRead', { userId });
},
onConversationDeleted: contactId => {
console.log('onConversationDeleted', { contactId });
},
onUserActivated: message => {
console.log('onUserActivated', { onUserActivated: message });
},
onUserConnect: message => {
console.log('onUserConnect', { userConnected: message });
},
onUserOnlineStatus: (userId, isOnline, timestamp) => {
console.log('onUserOnlineStatus', { userId, isOnline, timestamp});
},
onTypingStatus: (userId, status) => {
console.log('onTypingStatus', { userId, status});
}
}
});
2. Using script
tag
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>Development</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<script src="https://websdk.applozic.com/sdk.js"></script>
<script>
var applozicClient = new alClient('YOUR-APPLOZIC-APP-ID', {
events: {
onMessageReceived: ({ message }) => {
console.log('onMessageReceived', { message });
},
onMessageDelivered: (contactId, messageKey) => {
console.log('onMessageDelivered', { message });
},
onMessageRead: (contactId, messageKey) => {
console.log('onMessageRead', { contactId, messageKey });
},
onMessageSent: ({ message }) => {
console.log('onMessageSent', { message });
},
onMessageSentUpdate: message => {
console.log('onMessageSentUpdate', { sentMessageUpdate: message });
},
onMessageDeleted: (contactId, messageKey) => {
console.log('onMessageDeleted', { contactId, messageKey });
},
onConversationRead: userId => {
console.log('onConversationRead', { userId });
},
onConversationDeleted: contactId => {
console.log('onConversationDeleted', { contactId });
},
onUserActivated: message => {
console.log('onUserActivated', { onUserActivated: message });
},
onUserConnect: message => {
console.log('onUserConnect', { userConnected: message });
},
onUserOnlineStatus: (userId, isOnline, timestamp) => {
console.log('onUserOnlineStatus', { userId, isOnline, timestamp });
},
onTypingStatus: (userId, status) => {
console.log('onTypingStatus', { userId, status });
}
}
});
</script>
</head>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
Login a user
const isUserLoggedIn = async () => {
await applozicClient.init(); // Starts listening for events if user already logged in
if (applozicClient.loginResult) {
console.log({ loginResult: applozicClient.loginResult });
return true;
}
return false;
};
const login = async (userId, password) => {
if (await isUserLoggedIn()) {
// User is already logged in
// loginResult = applozicClient.loginResult;
// You can use `await applozicClient.logout()` to log out current user
} else {
const loginResult = await applozicClient.login('userId', 'password')
}
};
Logout a user
await applozicClient.logout()
APIs
Detailed documentation of the APIs can be found in the Applozic Core SDK.
ApplozicClient
ContactsApi
MessagesApi
FilesApi
GroupsApi
- addUserToGroup
- addUsersToGroups
- createGroup
- createOpenFriendList
- createUserFriendList
- deleteFriendList
- deleteGroup
- deleteGroups
- getFriendList
- groupInfo
- isUserPresent
- leaveGroup
- openGroup
- removeFromFriendList
- removeUserFromAllGroups
- removeUserFromGroup
- removeUsersFromGroups
- updateGroupInfo
- updateUserDetails
- userCount
- userGroupList
Changelog
https://github.com/AppLozic/Applozic-JS-SDK/blob/main/packages/core/CHANGELOG.md