Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2145] Facebook login event listener is not capturing the login event

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNeeds more info
Resolution Date2013-04-01T22:54:16.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsfacebook, iphone
ReporterMarco Schierhorn
AssigneeMauro Parra-Miranda
Created2013-03-26T13:31:43.000+0000
Updated2016-03-08T07:41:07.000+0000

Description

I have the problem that the Event Listener doesn't get called under specific circumstances. It seems that when I try to add a FB App again to my FB profile with the same permissions the Event Listener doesn't get called and the Facebook WebView simply get closed. I need the event listener to transfer the FB Token to our Website / Database and to deliver a notification to the user.
Titanium.Facebook.appid = "#####";
Titanium.Facebook.permissions = ['publish_stream', 'create_event', 'publish_actions', "email","user_about_me","publish_stream","publish_actions","user_interests","user_subscriptions","user_education_history","user_likes","user_birthday","user_location","user_status","user_website","friends_about_me","friends_games_activity","friends_location","friends_status","friends_website","friends_interests","friends_notes","friends_photos","friends_relationships","friends_subscriptions","friends_work_history","friends_activities","friends_education_history","friends_groups","friends_likes","friends_birthday"];
 
var fbLoginListener = function(e) {
    if (e.success) {
      util.alert(L('FacebookRightsSetted'), L('FacebookPermissions'));
    } else if (e.error) {
      util.alert(L('FacebookRightsSettedError') + e.error, L('FacebookPermissions'));
    } else if (e.cancelled) {
      util.alert(L('FacebookRightsSettedAbort'), L('FacebookPermissions'));
    }
    if (core.isDefined(Ti.Facebook.uid) && core.isDefined(Ti.Facebook.accessToken)) {
      star.transferFacebookToken(Ti.Facebook.uid, Ti.Facebook.accessToken, function() {
      }, function() {
        util.alert(L('FacebookTokenTransmitError'), L('FacebookPermissions'));
      });
    }
    exit();
  };

  var fbLogoutListener = function fbLogoutListener(e) {
    util.alert(L('FacebookPermissionsOpen'), L('FacebookPermissions'), function(e) {
      if (core.isDefined(e)) {
        if (e.index == 0) {
          Ti.Facebook.appid = config.facebook_app_id;
          Ti.Facebook.permissions = config.facebook_scope;
          Ti.API.info('FB Permission we want = ' + JSON.stringify(Ti.Facebook.permissions));
          Ti.Facebook.addEventListener('login', fbLoginListener);
          setTimeout(function() {Titanium.Facebook.authorize();}, 750);
        }
        Ti.Facebook.addEventListener('logout', fbLogoutListener);
      }
    }, ['Ok', L('Cancel')], true);
    fbPermissionAlert = false;
  }
 function facebookLogout() {
    Ti.Facebook.accessToken = null;
    Ti.Facebook.expirationDate = null;
    Ti.Facebook.uid = null;
    Ti.Facebook.loggedIn = false;

    var url = 'https://login.facebook.com';
    var client = Titanium.Network.createHTTPClient();
    client.clearCookies(url);
    Titanium.API.info("logout from facebook.com == success");

    var url = 'http://login.facebook.com';
    var client = Titanium.Network.createHTTPClient();
    client.clearCookies(url);
    if (Ti.Facebook.loggedIn == true) {
      Ti.Facebook.logout();
    } else {
      fbLogoutListener();
    }
  }
Ti.Facebook.addEventListener('logout', fbLogoutListener);
facebookLogout();


Comments

  1. Jamie Buckley 2013-04-01

    Hi Marco, Can you please provide some additional information on this issue: - Titanium Studio Version - Titanium SDK Version - iOS Version You can see the full guidelines of how to submit a ticket here: https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report

JSON Source