Creating a User object
A User
object needs to be initialised and then authenticated to use Applozic's features. A user object has a unique field userId
which is also the only mandatory field. You can create a User object as below:
var alUser = {
'userId' : userId, //Replace it with the userId of the logged in user NOTE : userId need to be string and +,*,? are not allowed chars in userId.
'password' : password, //Put password here
'authenticationTypeId' : 1,
'applicationId' : 'applozic-sample-app', //replace "applozic-sample-app" with App ID from Applozic Dashboard
'deviceApnsType' : 0 //Set 0 for Development and 1 for Distribution (Release)
};
Registering/Logging-in the user
Note
Please remember you have to log in once and only after you log out you must log in again. Use below code to check if the user is already logged in.
You can check if the user is logged in to applozic or not by using:
applozicChat.isLoggedIn(function(response){
if(response === 'true'){
// User is already logged in
}else if(response === 'false'){
// User isn't logged in yet
}
},function(error) {
});
You can authenticate the user with Applozic using the below methods. If the login request is from a new user then a new user account is created. If the user is an existing user then user authentication details are validated by the server.
applozicChat.login(alUser, function(response) {
//login success callback here
}, function(error) {
//login failure callback here
});
where applozicChat
is the instance of the Applozic chat plugin. You can initialise it as below:
var nativescript_applozic_chat = require("nativescript-applozic-chat");
import { ApplozicChat } from "nativescript-applozic-chat";
And then inside your function:
var applozicChat = new nativescript_applozic_chat.ApplozicChat();
var applozicChat = new ApplozicChat();
Updated 2 months ago
What's Next
Conversation |