Guest User

Untitled

a guest
Nov 28th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. var Notifications;
  2. var Cloud = require('ti.cloud');
  3.  
  4. (function() {
  5.  
  6. Notifications = function() {
  7.  
  8. Ti.API.info('Notifications ...');
  9.  
  10. var _registerDevice = function() {
  11. Ti.API.info('RegisterDevice');
  12. }
  13.  
  14. return {
  15.  
  16. cloudUserLogin : function() {
  17. //_registerDevice(_token);//_token is being populated in app.js for now
  18. Ti.API.info(' >>>>>>>> calling login - oOk');
  19.  
  20. //Cloud.debug = true;
  21.  
  22. Cloud.Users.login({
  23. login : "push123",
  24. password : "push123"
  25. }, function(e) {
  26. if (e.success) {
  27. var user = e.users[0];
  28. Ti.API.info('Logged in! Registering to channel as user =' + user.id);
  29. } else {
  30. Ti.API.info('error loggin in - ' + e);
  31. }
  32. });
  33. //loginUser("push123", "push123");
  34. },
  35.  
  36. registerDevice : function() {
  37. //ios only function
  38. if (Ti.Platform.osname == "iphone") {
  39. Ti.API.info(' Im iOS!');
  40. Notifications.cloudUserLogin();
  41.  
  42. } else {
  43. Ti.API.info('Im Android');
  44. Notifications.cloudUserLogin();
  45.  
  46. }
  47. }
  48. }
  49.  
  50. }();
  51. //OF.Util.Notifications
  52.  
  53. })();
Add Comment
Please, Sign In to add comment