- Source:
Example
Initialize ClearBladeAPI
initOptions = {systemKey: 'asdfknafikjasd3853n34kj2vc', systemSecret: 'SHHG245F6GH7SDFG823HGSDFG9'};
var cb = new ClearBlade();
cb.init(initOptions);
Classes
Methods
(static) init(options)
Parameters:
| Name | Type | Description |
|---|---|---|
options |
Object | This value contains the config object for initializing the ClearBlade module. A number of reasonable defaults are set for the option if none are set.
The connect options and their defaults are: {String} [systemKey] This is the app key that will identify your app in order to connect to the Platform {String} [systemSecret] This is the app secret that will be used in combination with the systemKey to authenticate your app {String} [URI] This is the URI used to identify where the Platform is located. Default is https://platform.clearblade.com {String} [messagingURI] This is the URI used to identify where the Messaging server is located. Default is platform.clearblade.com {Number} [messagingPort] This is the default port used when connecting to the messaging server. Default is 8904 {Boolean} [logging] This is the property that tells the API whether or not the API will log to the console. This should be left `false` in production. Default is false {Number} [callTimeout] This is the amount of time that the API will use to determine a timeout. Default is 30 seconds {Boolean} [mqttAuth] Setting this to true and providing an email and password will use mqtt websockets to authenticate, rather than http. {String} [messagingAuthPort] is the port that the messaging auth websocket server is listening on. |
- Source:
(static) isCurrentUserAuthenticated(callback)
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function |
- Source:
Example
cb.isCurrentUserAuthenticated(function(err, body) {
if(err) {
//handle error
} else {
//check authentication boolean
}
})
(static) loginAnon(callback)
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function |
- Source:
Example
cb.loginAnon(function(err, body) {
if(err) {
//handle error
} else {
//do post login stuff
}
})
(static) loginUserMqtt(email, password, callback)
Parameters:
| Name | Type | Description |
|---|---|---|
email |
String | |
password |
String | |
callback |
function |
- Source:
Example
cb.loginUserMqtt("[email protected]","secret_password", function(err, body) {
if(err) {
//handle error
} else {
//do post login stuff
}
})
(static) logoutUser(callback)
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function |
- Source:
Example
cb.logoutUser(function(err, body) {
if(err) {
//handle error
} else {
//do post logout stuff
}
})
(static) registerUser(email, password, callback)
Parameters:
| Name | Type | Description |
|---|---|---|
email |
String | the users email |
password |
String | the password for the user |
callback |
function | returns a Boolean error value and a response as parameters |
- Source:
Example
Register User
cb.registerUser("[email protected]", "qwerty", function(err, body) {
if(err) {
//handle error
} else {
console.log(body);
}
});
(static) sendPush(users, payload, appId, callback)
Parameters:
| Name | Type | Description |
|---|---|---|
users |
Array | The list of users to which the message will be sent |
payload |
Object | An object with the keys 'alert', 'badge', 'sound' |
appId |
string | A string with appId that identifies the app to send to |
callback |
function | A function like `function (err, data) {}` to handle the response |
- Source:
(static) setUser(email, authToken)
Parameters:
| Name | Type | Description |
|---|---|---|
email |
String | the email of the user |
authToken |
String | the authToken for the user |
- Source: