Skip to content

Instantly share code, notes, and snippets.

@egomez99
Created July 31, 2012 01:52
Show Gist options
  • Save egomez99/3212674 to your computer and use it in GitHub Desktop.
Save egomez99/3212674 to your computer and use it in GitHub Desktop.
Cloud Users Login method BOTH PLATFORMS
Ti.include('mylogin_window.js');
Notifications.registerDevice();
var Notifications;
var Cloud = require('ti.cloud');
(function() {
Notifications = function() {
Ti.API.info('Notifications ...');
var _registerDevice = function() {
Ti.API.info('RegisterDevice');
}
return {
cloudUserLogin : function() {
//_registerDevice(_token);//_token is being populated in app.js for now
Ti.API.info(' >>>>>>>> calling login - oOk');
//Cloud.debug = true;
Cloud.Users.login({
login : "push123",
password : "push123"
}, function(e) {
if (e.success) {
var user = e.users[0];
Ti.API.info('Logged in! Registering to channel as user =' + user.id);
} else {
Ti.API.info('error loggin in - ' + e);
}
});
//loginUser("push123", "push123");
},
registerDevice : function() {
//ios only function
if (Ti.Platform.osname == "iphone") {
Ti.API.info(' Im iOS!');
Notifications.cloudUserLogin();
} else {
Ti.API.info('Im Android');
Notifications.cloudUserLogin();
}
}
}
}();
//OF.Util.Notifications
})();
- iOS trace
~~~
[INFO] onforceACS/1.0 (2.1.0.GA.6e3cab6)
[INFO] Notifications ...
[INFO] Im iOS!
[INFO] >>>>>>>> calling login -
[INFO] Logged in! Registering to channel as user =5016d89200204417fb1de15d
~~~
- Android stack trace
~~~
07-31 15:17:51.084: I/ActivityManager(499): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.onforce.OnForce/.OnforceacsActivity } from pid 870
07-31 15:17:51.170: D/ActivityRenderTarget(870): onPause
07-31 15:17:51.272: I/TiRootActivity(3998): (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
07-31 15:17:51.389: D/Module(3998): Loading module: ti.cloud -> Resources/ti.cloud.js
07-31 15:17:51.483: I/TiAPI(3998): Notifications ...
07-31 15:17:51.483: I/TiAPI(3998): Im Android
07-31 15:17:51.483: I/TiAPI(3998): >>>>>>>> calling login
07-31 15:17:51.600: D/dalvikvm(3998): Trying to load lib /data/data/com.onforce.OnForce/lib/libtiverify.so 0x4051d878
07-31 15:17:51.608: D/dalvikvm(3998): Added shared lib /data/data/com.onforce.OnForce/lib/libtiverify.so 0x4051d878
07-31 15:17:51.608: I/TiRootActivity(3998): (main) [0,0] checkpoint, on root activity resume. activity = com.onforce.OnForce.OnforceacsActivity@40632c10
07-31 15:17:51.670: I/ActivityManager(499): Displayed com.onforce.OnForce/.OnforceacsActivity: +415ms
07-31 15:17:53.545: I/TiAPI(3998): Logged in! Registering to channel as user =5016d89200204417fb1de15d
~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment