Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2056] Android: Second launch of app keeps Facebook session logged in but FB Connect dialog shows empty

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionInvalid
Resolution Date2011-04-15T03:09:12.000+0000
Affected Version/sn/a
Fix Version/sBacklog
ComponentsAndroid
Labelsandroid, defect, facebook
ReporterBill Dawson
AssigneeBill Dawson
Created2011-04-15T03:09:10.000+0000
Updated2017-03-02T19:25:40.000+0000

Description

app.js:

/*global Ti, Titanium, alert, JSON */
Titanium.UI.setBackgroundColor('#000');
var win = Titanium.UI.createWindow({  
    title:'Test',
    backgroundColor:'#fff',
    exitOnClose: true
});

var fbButton = Titanium.Facebook.createLoginButton({
    'style':'wide',
    'apikey':'9494e611f2a93b8d7bfcdfa8cefdaf9f',
    'sessionProxy':'http://api.appcelerator.net/p/fbconnect/',
    bottom:10
});
win.add(fbButton);

var status = Ti.UI.createButton({
    title:'Publish Status', width:200, height:40, top:60
});
win.add(status);

status.addEventListener('click', function()
{
    if (!Titanium.Facebook.isLoggedIn())
    {
        Ti.UI.createAlertDialog({title:'Facebook', message:'Login before publishing to your stream'}).show();
        return;
    }

    Titanium.Facebook.publishStream("Set your status",null,null,function(r)
    {
        if (r.success)
        {
            Ti.UI.createAlertDialog({title:'Facebook', message:'Your status was published'}).show();
        }
        else
        {
            Ti.UI.createAlertDialog({title:'Facebook', message:'You canceled, or there was an error'}).show();
        }
    });
    
});

win.open();

Steps to reproduce:

  • Launch this app.js.

  • Use the "Connect with Facebook" button to login to Facebook.

  • After you have successfully logged in, go back to Ti Developer and re-launch the application. (You don't need to click the "Publish Status" button at all in this round.

  • When the application re-launches, you should see that you are still logged into Facebook (the blue Facebook button will say "logout" instead of "Connect with Facebook" -- i.e., you are still logged in.)

  • Now click the "Publish Status" button. An empty Facebook Connect view will show up instead of the expected view which should show you fields in which to type and submit your status.

Attachments

FileDateSize
2056_1_4_x.diff2011-04-15T03:09:11.000+00003993

Comments

  1. Bill Dawson 2011-04-15

    Attached .diff to help with logging. Haven't committed any of this yet.

  2. Leo Acevedo 2011-04-15

    I could overcome this problem by erasing the activity cookies in FacebookModule.executeLogin.I also unsave the session so that if another user will log in, it will be asked for credentials.

    CookieSyncManager.createInstance(activity);
    CookieSyncManager csm = CookieSyncManager.getInstance();
    CookieManager cm = CookieManager.getInstance();
    cm.removeAllCookie();
    csm.sync();
    session.unsave(activity);

    After this I still had a FileNotFoundException when loading https://graph.facebook.com/me?var=val&;...&method=me">https://graph.facebook.com/me?var=val&;amp;...&method=me. It worked for me after commenting out the following line on FBRequest.java (method callWithAnyData() )

    mParams.put("method", mMethod);

    Hope this may be of help

  3. Bill Dawson 2011-04-15

    With the Titanium 1.6.0 changes to the facebook module, the equivalent code for the above test case would now be:

       Titanium.UI.setBackgroundColor('#000');
       Ti.Facebook.appid = "YOUR FACEBOOK APP ID";
       var win = Titanium.UI.createWindow({  
           title:'Test',
           backgroundColor:'#fff',
           exitOnClose: true
       });
       
       var fbButton = Titanium.Facebook.createLoginButton({
           'style':'wide',
           bottom:10
       });
       win.add(fbButton);
       
       var status = Ti.UI.createButton({
           title:'Publish Status', width:200, height:40, top:60
       });
       win.add(status);
       
       status.addEventListener('click', function()
       {
           if (!Titanium.Facebook.loggedIn)
           {
               Ti.UI.createAlertDialog({title:'Facebook', message:'Login before publishing to your stream'}).show();
               return;
           }
           Ti.Facebook.dialog("feed", {},function(){});
       });
       
       win.open();
       

    I cannot re-create the failcase with the new Facebook module, so I'll mark this as "invalid" (though it was not originally invalid) to close it.

  4. Bill Dawson 2011-04-15

    @Leo Acevedo: regarding destroying FB sessions, you might be interested in the approached described in #3025.

  5. Leo Acevedo 2011-04-15

    @Bill Dawson: indeed, it would have been great to know this in advance, thanks a lot :)

  6. Lee Morris 2017-03-02

    Closed as invalid.

JSON Source