Trigger facebook login
Is there a way to trigger the facebook login screen via a function? Right now the only way to do is to create the login button with Titanium.Facebook.createLoginButton.
5 Answers
-
The
Titanium.Facebook.authorize()
function opens the facebook screen for you to log in. -
I would also like an answer to this.
-
anyone?
-
I really can't understand why there's a button in order to trigger the login window. it doesn't make any sense.
I'd rather have a login/logout method. -
I did this and it is working for me. The code is in an option dialog so you may be able to simplify it depending on where you want to use it:
Titanium.Facebook.appid = "nnnnnn";
Titanium.Facebook.permissions = ['publish_stream']; // Permissions your app needs
Titanium.Facebook.addEventListener('login', function(e)
{
if (e.success)
{
alert('Logged In- Click to Post');
} else if (e.error)
{
alert('Click button to login to FB');
alert(e.error);
} else if (e.cancelled)
{
alert("Cancelled");
}
});
Titanium.Facebook.authorize();// Now create the status message after you've confirmed that authorize() succeeded
Titanium.Facebook.requestWithGraphPath('me/feed', {message:statusText.value}, "POST", function(e)
{
if (e.success)
{
alert("Successful Post to FB");
}
else
{
if (e.error)
{
alert(e.error);
}
else
{
alert("Unkown result");
}
}
});