Subscribe to Locations
To subscribe to locations from a device, connect to the MQTT API and subscribe it to the locations topic for that device.
To subscribe to locations the MQTT topic is:
devices/{device.id}/locations
Replace {device.id}
with your device ID (should begin with dev_
).
Example Code
Subscribe to all device locations using the Wia SDK
x
// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');
// Subscribe to all locations for a device
// Replace 'dev_abc123' with your device ID
wia.locations.subscribe({
device: 'dev_abc123',
}, function(location) {
console.log(location);
});
// Connect to the MQTT API
wia.stream.connect();