new Presence()
presence.js, line 7
Represents presence details of a user. Instance of presence is retrieved every time a user fetches his or someone else's presence.
Example
// 'blt12sampleb09157' is uid of an Application user on Built.io Backend
var user = app.User('blt12sampleb09157');
user
.getPresence()
.then(function(presence){
// console.log(presence.getState());
});
Methods
-
enable(enable){Presence}
presence.js, line 46 -
You can enable/disable your presence using this function. Disable your presence if you don't want it to be broadcast, or its state to be set. This is similar to going "invisible".
Name Type Description enable
Boolean Set it to true to enable presence. Set to false for otherwise. Example
var user = app.User('blt12sampleb09157'); user .getPresence() .then(function(presence){ var newPresence = presence.enable(true); });
-
getApplicationUser(){Boolean}
presence.js, line 150 -
Gets the application user whose presence was broadcast When a user logs in, his presence is broadcast to all users who have requested for his presence updates. To know the user whose presence was updated, use this method.
Example
var User = app.User; User.on('presence',function(presence){ console.log(presence.getApplicationUser()); })
-
getLastSeen(){Presence}
presence.js, line 65 -
Gets the time when the user was last seen online
Example
var User = app.User; User .getCurrentUserPresence() .then(function(presence){ var lastSeen = presence.getLastSeen() });
-
getStatus(){Presence}
presence.js, line 83 -
Gets whether the user is online or offline
Example
User .getCurrentUserPresence() .then(function(presence){ var status = presence.getStatus() });
-
isEnabled(){Boolean}
presence.js, line 133 -
Checks whether the user's presence is enabled
Example
var User = app.User; User .getCurrentUserPresence() .then(function(presence){ console.log(presence.isEnabled()); });
-
save(){Promise.<Presence>}
presence.js, line 101 -
Saves your presence details on the server
Example
var user = app.User('blt12sampleb09157'); user .getPresence() .then(function(presence) { presence .setWhiteList(['blt111sample01122', 'blt111sample01133']) .setStatusMessage({ message: 'Hello' }) .save() .then(function(presence) { console.log(presence.toJSON()); // updated presence details }); });