When a friend texts you an App (or package)-name, your phone will automatically launch that App.
To use this on{X} Recipe, simply copy the code below and modify if needed.
////////////////////////////////////////////////////////////////
//////////////////// Launch App through SMS ////////////////////
//// Author: Philipp Zoechner / Website: http://zoechner.com ///
//////////// Date: 30.06.2012 // Version: 1.0 //////////////////
////////////////////////////////////////////////////////////////
// append additional phone numbers like: , "+xxxxx"
var friendNo = new Array("+43xxxxxxxxxx", "+1xxxxxxxxxx");
// 0 = start per App-name; 1 = start per Package-name (i.e. com.android.calendar)
var appKind = 0;
device.messaging.on('smsReceived', function (sms) {
for(i=0;i<friendNo.length;i++) {
if (sms.data.from === friendNo[i]) {
var appName = sms.data.body.trim(); // Case sensitive!
console.log('Started script: Launching ' + appName + ' app from ' + friendNo[i]);
switch(appKind) {
case 0:
device.applications.launch(appName, {}, function (error) {
if (error !== null)
console.error('Failed to launch app ' + appName + 'from ' + friendNo[i] + ', please verify the application name; ' + error);
});
device.notifications.createNotification(friendNo[i] + ' started ' + appName + '.').show();
break;
case 1:
device.applications.launchPackage(appName, {}, function (error) {
if (error !== null)
console.error('Failed to launch app ' + appName + 'from ' + friendNo[i] + ', please verify the application name; ' + error);
});
device.notifications.createNotification(friendNo[i] + ' started ' + appName + '.').show();
break;
}
console.log('Completed script: Launching ' + appName + ' app from ' + friendNo[i]);
}
}
});
Views