new Installation(uid){Installation}
Name | Type | Description |
---|---|---|
uid |
string | object | The uid for the Installation, or a JavaScript object with initial values |
Example
// 'blt5d4sample2633b' is a dummy Application API key
var app = Built.App('blt5d4sample2633b');
var installation = app.Installation({
device_token : "Sample_device_token";
});
Methods
-
staticInstallation.off(event, callback){Installation}
realtime.js, line 2010 -
[Only avaliable with realtime plugin]
This function unregisters one or all event listener(s) from Installation constructor.Name Type Description event
String The event whose listener needs to be unregistered [Optional] callback
function The callback function used while registering [Optional] Throws:
-
new Error('Callback function to be removed is missing')
-
new Error('Event name is missing');
Example
// 'blt5d4sample2633b' is a dummy Application API key // app.Installation returns a 'Installation' constructor var app = Built.App('blt5d4sample2633b').enableRealtime(); var Installation = app.Installation; function cb(data){ console.log(data); } // Sets up a listener for create event Installation.on('delete',cb); // Sets up a listener for broadcast event Installation.on('broadcast',cb); // Specifically removes the delete listener Installation.off('delete',cb); // Removes all listeners on Person Installation.off(); // Removes all callbacks attached for delete event on this resource Installation.off('delete'); // Throws "Event name is missing" Installation.off(cb)
-
-
staticInstallation.on(event, callback){Installation}
realtime.js, line 1510 -
[Only avaliable with realtime plugin]
This function registers an event listener on Installation constructor.Given below is the list of supported events.
- Create
- Update
- Delete
- Broadcast
Create event is triggered when a new installation is created on this application. Registered callback is invoked with the created installation's details.
Update event is triggered when the content and/or the ACL of any installation object on this application is modified. Registered callback is invoked with updated installation's details.
Delete event is triggered when any installation object on this application is deleted. Registered callback is invoked with the deleted installation's details.
Broadcast event is triggered when a message is broadcasted across all installation objects. Registered callback is invoked with the broadcasted message.
Name Type Description event
String The event on which the listener should be registered callback
function The callback function to be invoked on event trigger Example
// 'blt5d4sample2633b' is a dummy Application API key // app.Installation returns a 'Installation' constructor // 'blt111sample2211r' is uid of an object on Built.io Backend var app = Built.App('blt5d4sample2633b').enableRealtime(); var Installation = app.Installation; Installation.on('create', function(jsonObject) { // Newly created installation's details }); Installation.on('update', function(jsonObject) { // Updated installation's details }); Installation.on('delete', function(jsonObject) { // Deleted installation's details }); Installation.on('broadcast', function(message) { // The message broadcasted across all installation objects });
-
getCredentailsName(){String}
installation.js, line 158 -
Credentails name property is used to detect to which credentials this installation data belongs
Example
// 'blt5d4sample2633b' is a dummy Application API key // 'blt12sampleb09157' is uid of an object on Built.io Backend var installation = Built.App('blt5d4sample2633b').Installation('blt12sampleb09157'); installation.fetch() .then(function(installation){ var credentailsName = installation.getCredentailsName(); });
-
getDeviceToken(){String}
installation.js, line 139 -
Gets the device token
Example
// 'blt5d4sample2633b' is a dummy Application API key // 'blt12sampleb09157' is uid of an object on Built.io Backend var installation = Built.App('blt5d4sample2633b').Installation('blt12sampleb09157'); installation.fetch() .then(function(installation){ var token = installation.getDeviceToken(); });
-
getDeviceType(){String}
installation.js, line 176 -
Gets the device type
Example
// 'blt5d4sample2633b' is a dummy Application API key // 'blt12sampleb09157' is uid of an object on Built.io Backend var installation = Built.App('blt5d4sample2633b').Installation('blt12sampleb09157'); installation.fetch() .then(function(installation){ var type = installation.getDeviceType(); });
-
getSubscribedChannelList(){Array}
installation.js, line 195 -
Gets a list of subscribed channels by this device
Throws:
new Error("Uid not found")Example
// 'blt5d4sample2633b' is a dummy Application API key // 'blt12sampleb09157' is uid of an object on Built.io Backend var installation = Built.App('blt5d4sample2633b').Installation('blt12sampleb09157'); installation.fetch() .then(function(installation){ var list = installation.getSubscribedChannelList(); })
-
off(event, callback){Installation}
realtime.js, line 2053 -
[Only avaliable with realtime plugin]
This function unregisters one or all event listener(s) from Installation instance.Name Type Description event
String The event whose listener needs to be unregistered [Optional] callback
function The callback function used while registering [Optional] Throws:
-
new Error('Callback function to be removed is missing')
-
new Error('Event name is missing');
Example
// 'blt5d4sample2633b' is a dummy Application API key // app.Installation returns an instance of installation class // 'blt111sample2211r' is uid of an object on Built.io Backend var app = Built.App('blt5d4sample2633b').enableRealtime(); var installation = app.Installation('blt111sample2211r'); function cb(data){ console.log(data); } // Sets up a listener for create event installation.on('delete',cb); // Sets up a listener for broadcast event installation.on('broadcast',cb); // Specifically removes the delete listener installation.off('delete',cb); // Removes all listeners on Person installation.off(); // Removes all callbacks attached for delete event on this resource installation.off('delete'); // Throws "Event name is missing" installation.off(cb)
-
-
on(event, callback){Installation}
realtime.js, line 1560 -
[Only avaliable with realtime plugin]
This function registers a event listener on Installation instance.Given below is the list of supported events.
- Update
- Delete
- Broadcast
Update event is triggered when the content and/or the ACL of a user object on this application is modified. Registered callback is invoked with the updated user's details.
Delete event is triggered when a user object on this application is deleted. Registered callback is invoked with the deleted user's details.
Broadcast event is triggered when a message is broadcast over this user object. Registered callback is invoked with the broadcast message.
Name Type Description event
String The event on which the listener should be registered callback
function The callback function to be invoked on event trigger Example
// 'blt5d4sample2633b' is a dummy Application API key // app.Installation() returns an instance of Installation class // 'blt111sample2211r' is uid of an object on Built.io Backend var app = Built.App('blt5d4sample2633b').enableRealtime(); var installation = app.Installation('blt111sample2211r'); installation.on('update', function(jsonObject) { // Updated installation's details }); installation.on('delete', function(jsonObject) { // Deleted installation's details }); installation.on('broadcast', function(message) { // The message broadcasted across this installation object });
-
save(){Promise.<Installation>}
installation.js, line 222 -
Fires an update call when the installation object has a uid property, else fires a create call
Example
// 'blt5d4sample2633b' is a dummy Application API key // 'blt12sampleb09157' is uid of an object on Built.io Backend var inst = Built.App('blt5d4sample2633b').Installation('blt12sampleb09157'); inst .setDeviceType("android") .setDeviceToken("dummy_device_token") .subscribeChannels(["project.object.create"]); .save() .then(function(inst){ })
-
setCredentailsName(credentailsName){Installation}
installation.js, line 80 -
Sets the credentails name property which is used to detect to which credentials this installation data belongs.
Name Type Description credentailsName
String Name for this credentail Example
// 'blt5d4sample2633b' is a dummy Application API key // 'blt12sampleb09157' is uid of an object on Built.io Backend var installation = Built.App('blt5d4sample2633b').Installation('blt12sampleb09157'); installation = installation.setCredentailsName('testName');
-
setCurrentTimeZone(){Installation}
installation.js, line 29 -
Sets the timezone for this installation as the current timezone
Example
// 'blt5d4sample2633b' is a dummy Application API key var installation = Built.App('blt5d4sample2633b').Installation(); installation = installation.setCurrentTimeZone();
-
setDeviceToken(token){Installation}
installation.js, line 46 -
Set the device token
Name Type Description token
String The token to be given Example
// 'blt5d4sample2633b' is a dummy Application API key var installation = Built.App('blt5d4sample2633b').Installation(); installation = installation.setDeviceToken('sample_device_token');
-
setDeviceType(type){Installation}
installation.js, line 64 -
Set the device type
Name Type Description type
String The type of device being used. Supported devices are Android and iOS. Example
// 'blt5d4sample2633b' is a dummy Application API key // 'blt12sampleb09157' is uid of an object on Built.io Backend var installation = Built.App('blt5d4sample2633b').Installation('blt12sampleb09157'); installation = installation.setDeviceType('android');
-
subscribeChannels(channels){Installation}
installation.js, line 96 -
Subscribes to a given set of channels
Name Type Description channels
Array Array of channels that should be subscribed Example
// 'blt5d4sample2633b' is a dummy Application API key // 'blt12sampleb09157' is uid of an object on Built.io Backend var installation = Built.App('blt5d4sample2633b').Installation('blt12sampleb09157'); installation = installation.subscribeChannels(['project.object.create']);
-
unsubscribeChannels(channels){Installation}
installation.js, line 116 -
Unsubscribes from a given set of channels
Name Type Description channels
Array Array of channels that should be subscribed Example
// 'blt5d4sample2633b' is a dummy Application API key // 'blt12sampleb09157' is uid of an object on Built.io Backend var installation = Built.App('blt5d4sample2633b').Installation('blt12sampleb09157'); installation.fetch() .then(function(installation){ installation.unsubscribeChannels(['project.object.create']); });