on{X} lets you control and extend the capabilities of your Android phone using a JavaScript API to remotely program it.
Kinda like ifttt but then based on actions that happen on your mobile: an SMS being received, a location being entered/left, a change in mode of transport (from car to walking), etc.
A recipe like Text my wife “I’m on my way” when I leave work would programmatically end up being:
// Initializing variables
var friend = { name : "my wife",phoneNumber : "+1234567890" } ;
var messageText = "I'm on my way";
var action = "exit"; // leaving
var location = { name : "work",latitude : "40.771442",longitude : "-73.974295" } ;
// create a geo region for the trigger to take place at
var region = device.regions.createRegion({
latitude: parseFloat(location.latitude, 10),
longitude: parseFloat(location.longitude, 10),
name: location.name,
radius: 1000
});
// register a callback which sends a message when entering/exiting the region (depends on action)
region.on(action, function (){
device.messaging.sendSms({
to: friend.phoneNumber,
body: messageText
},
function (err) {
if (err) {
console.error('Error sending text message: ' + JSON.stringify(err));
}
}
);
});
// start monitoring the region
device.regions.startMonitoring(region);
All can be configured via the website. Really neat!
(via teusje)