on{X} – Automate your life

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!

on{X} →

(via teusje)

Published by Bramus!

Bramus is a Freelance Web Developer from Belgium. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.