Print MOCA SDK version
MOCA.version (function (version) {
// ...
});
Get MOCA app key:
MOCA.appKey (function (key) {
// ...
});
Get MOCA app secret:
MOCA.appSecret (function (secret) {
// ...
});
Check if MOCA was initialized:
if (MOCA.initialized(function (isInited)) {
if (isInited) {
// ...
} else {
// ...
}
}
Check if MOCA proximity is enabled:
if (MOCA.proximityEnabled(function (enabled)) {
if (enabled) {
// ...
} else {
// ...
}
}
Enable MOCA proximity:
MOCA.setProximityEnabled(true, function () {
// ...
});
Get log level:
MOCA.logLevel (function (level) {
// ...
});
Set log level
// var level = "info" | "debug" | "trace" | "warning" | "error" | "off"
MOCA.setLogLevel (level, function () {
// ...
});
Login user:
Login the user with every app startup
After launching the app, check whether the user is still logged in or not. If the user is still logged in, perform a new 'MOCA login'
MOCA.login (userId, function () {
// ...
});
Logout current user:
MOCA.logout (function () {
// ...
});
Check if user has been logged in:
MOCA.userLoggedIn (function (isLoggedIn) {
if (isLoggedIn) {
// ...
} else {
// ...
}
});
Perform asynchronous fetch of beacons/campaigns data from cloud:
MOCA.performFetch (function (data) {
// ...
});
Get custom property by key:
MOCA.customProperty (key, function (dictionary) {
// ...dictionary -> {"requestedProperty": "value"} or {} if not found
});
Set custom property (key/value):
MOCA.setCustomProperty (key, value, function () {
// ...
});
Get MOCA instance unique ID:
MOCAInstance.identifier (function (iid) {
// ...
});
Get app session number:
MOCAInstance.session (function (sessionNumber) {
// ...
});
Get device push token
MOCAInstance.deviceToken (function (token) {
// ...
});
Get place device is currently visiting
- It returns an array with the place(s) you are currently visiting
- Combine this call with the
addEnterPlaceListener
callback to ensure you detect places correctly.
MOCA.placesInside(function (e) {
console.log("places inside: ");
console.log(e);
});