Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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.

— asked April 23rd 2010 by Sj Singh
  • facebook
  • login
0 Comments

5 Answers

  • The Titanium.Facebook.authorize() function opens the facebook screen for you to log in.

    — answered October 12th 2011 by cant delete
    permalink
    0 Comments
  • I would also like an answer to this.

    — answered April 26th 2010 by Sindre Sorhus
    permalink
    0 Comments
  • anyone?

    — answered May 4th 2010 by Peter Lum
    permalink
    0 Comments
  • 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.

    — answered May 22nd 2010 by André Cassal
    permalink
    0 Comments
  • 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");
    }
    }
    });

    — answered September 30th 2011 by Patty Mapes
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.