Skip to content

Instantly share code, notes, and snippets.

@skounis
Created January 3, 2014 07:30
Show Gist options
  • Save skounis/8234260 to your computer and use it in GitHub Desktop.
Save skounis/8234260 to your computer and use it in GitHub Desktop.
var Cloud = require('ti.cloud');
//FirstView Component Constructor
function FirstView() {
//create object instance, a parasitic subclass of Observable
var self = Ti.UI.createView({
backgroundColor: '#232323'
});
// Create a Button.
var aButton = Ti.UI.createButton({
title : 'Send Email',
height : 'auto',
width : '200',
backgroundColor: '#ffffff',
});
// Listen for click events.
aButton.addEventListener('click', function() {
Cloud.Emails.send({
template : 'default',
recipients : 'skounis@gmail.com',
foo : 'the foo',
bar : 'the bar'
}, function(e) {
if (e.success) {
alert('Success');
} else {
alert('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
}
});
});
// Add to the parent view.
self.add(aButton);
return self;
}
module.exports = FirstView;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment