Advertisement
Guest User

Untitled

a guest
Sep 8th, 2017
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. var win = Ti.UI.createWindow({
  2. backgroundColor : '#ccc',
  3. title : 'Cloud Notification'
  4. });
  5. var Cloud = require('ti.cloud');
  6. var submit = Ti.UI.createButton({
  7. title : 'Upload Photo',
  8. color : '#000',
  9. height : 60,
  10. width : 200,
  11. top : 100,
  12. });
  13.  
  14. win.add(submit);
  15.  
  16. submit.addEventListener('click', function(e) {
  17. loginDefault();
  18. });
  19.  
  20. function uploadPhoto(e){
  21. Cloud.Photos.create({
  22. photo: Titanium.Filesystem.getFile('DefaultIcon.png')
  23. }, function (e) {
  24. if (e.success) {
  25. var photo = e.photos[0];
  26. alert('Success:\n' +
  27. 'id: ' + photo.id + '\n' +
  28. 'filename: ' + photo.filename + '\n' +
  29. 'size: ' + photo.size,
  30. 'updated_at: ' + photo.updated_at);
  31. } else {
  32. alert('Error:\n' +
  33. ((e.error && e.message) || JSON.stringify(e)));
  34. }
  35. });
  36. }
  37.  
  38. function loginDefault(e) {
  39.  
  40. Cloud.Users.create({
  41. email: 'test1@mycompany.com',
  42. first_name: 'test_firstname1',
  43. last_name: 'test_lastname1',
  44. password: 'test_password1',
  45. password_confirmation: 'test_password1'
  46. }, function (e) {
  47. if (e.success) {
  48. var user = e.users[0];
  49. alert('Success:\n' +
  50. 'id: ' + user.id + '\n' +
  51. 'sessionId: ' + Cloud.sessionId + '\n' +
  52. 'first name: ' + user.first_name + '\n' +
  53. 'last name: ' + user.last_name);
  54. uploadPhoto();
  55.  
  56. } else {
  57. alert('Error:\n' +
  58. ((e.error && e.message) || JSON.stringify(e)));
  59. }
  60. });
  61.  
  62. }
  63.  
  64. win.open();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement