Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var win = Ti.UI.createWindow({
- backgroundColor : '#ccc',
- title : 'Cloud Notification'
- });
- var Cloud = require('ti.cloud');
- var submit = Ti.UI.createButton({
- title : 'Upload Photo',
- color : '#000',
- height : 60,
- width : 200,
- top : 100,
- });
- win.add(submit);
- submit.addEventListener('click', function(e) {
- loginDefault();
- });
- function uploadPhoto(e){
- Cloud.Photos.create({
- photo: Titanium.Filesystem.getFile('DefaultIcon.png')
- }, function (e) {
- if (e.success) {
- var photo = e.photos[0];
- alert('Success:\n' +
- 'id: ' + photo.id + '\n' +
- 'filename: ' + photo.filename + '\n' +
- 'size: ' + photo.size,
- 'updated_at: ' + photo.updated_at);
- } else {
- alert('Error:\n' +
- ((e.error && e.message) || JSON.stringify(e)));
- }
- });
- }
- function loginDefault(e) {
- Cloud.Users.create({
- email: 'test1@mycompany.com',
- first_name: 'test_firstname1',
- last_name: 'test_lastname1',
- password: 'test_password1',
- password_confirmation: 'test_password1'
- }, function (e) {
- if (e.success) {
- var user = e.users[0];
- alert('Success:\n' +
- 'id: ' + user.id + '\n' +
- 'sessionId: ' + Cloud.sessionId + '\n' +
- 'first name: ' + user.first_name + '\n' +
- 'last name: ' + user.last_name);
- uploadPhoto();
- } else {
- alert('Error:\n' +
- ((e.error && e.message) || JSON.stringify(e)));
- }
- });
- }
- win.open();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement