I've developed an application which have a screen to Login to the application.I need to display the details of the current user in main page.It works well when I logging into the app at first time. But i'm getting an error : You need to sign in or sign up before continuing when i try to sign in again after logout. There is no issue in android os with same code
Here is a sample code,
var win = Ti.UI.createWindow({
backgroundColor : '#520000'
});
var btnLogin = Ti.UI.createButton({
title : 'Login',
top : '20%',
width : '50%'
});
var Cloud = require('ti.cloud');
win.add(btnLogin);
win.open();
btnLogin.addEventListener('click', Login);
function Login(){
Cloud.Users.login({
login: 'anand@gmail.com',
password: 'anandt'
}, function (e) {
if (e.success) {
var user = e.users[0];
var mainWin = Ti.UI.createWindow({
backgroundColor : '#005200',
url : 'logout.js'
});
mainWin.open();
} else {
alert('Error: ' + ((e.error && e.message) || JSON.stringify(e)));
}
});
}
Main page of application
var Cloud = require('ti.cloud');
var logoutWin = Ti.UI.currentWindow;
var btnLogout = Ti.UI.createButton({
title : 'Logout',
top : '20%',
width : '50%'
});
logoutWin.add(btnLogout);
logoutWin.addEventListener('open', function(){
Cloud.Users.showMe(function (e) {
if (e.success) {
var user = e.users[0];
alert('user is ' + 'first name: ' + user.first_name + ' ' + 'last name: ' + user.last_name);
} else {
alert('Error: ' + ((e.error && e.message) || JSON.stringify(e)));
}
});
});
btnLogout.addEventListener('click', Logout);
function Logout()
{
Cloud.Users.logout(function (e) {
if (e.success) {
logoutWin.close();
} else {
alert('Error: ' + ((e.error && e.message) || JSON.stringify(e)));
}
});
}
This is the screen showing after the user logged in for the first time without any logout
This is the screen showing after the user logged in with one or more logout(without restarting the app)
Any help will be appreciated
Loading up the window with a URL is causing the session ID to get mangled between the contexts. Don't use URLs.