{ "id": "63657", "key": "TIMOB-3025", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11241", "name": "Release 1.6.0 M08", "archived": true, "released": true, "releaseDate": "2011-02-07" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T02:00:42.000+0000", "created": "2011-04-15T03:35:01.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [ "android", "defect", "facebook", "release-1.6.0", "reported-1.6.0" ], "versions": [], "issuelinks": [], "assignee": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2011-04-17T02:00:42.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}

Some app developers want to clear the saved Facebook session\ninformation when a user backs out of an app, so that the session\ninfo doesn't automatically get remembered the next time the app is\nstarted. I want to recommend to them that they should use the\ndestroy event of the root activity, such as in this\nexample app.js:

\n
\nTitanium.UI.setBackgroundColor('#000');\nTi.Facebook.appid = \"PUT A FACEBOOK APP ID HERE\";\nvar win = Titanium.UI.createWindow({  \n    title:'Test',\n    backgroundColor:'#fff',\n    exitOnClose: true\n});\n\nTi.Android.currentActivity.addEventListener('destroy',function(){\n    Ti.API.info('Root activity destroying');\n    Ti.Facebook.logout();\n});\nwin.add( Ti.Facebook.createLoginButton({style: 'wide'}) );\nwin.open();\n
\n

Run that example and login to Facebook. Then completely back out\nof the application. Then go back in to the application --\nunfortunately you'll probably see the facebook button still says\n\"logout\", so it thinks it is logged in even though we called\nlogout() when the user backed out of the app, which is\nwhen destroy occurs (you can see that\nlogout() really does get called if you watch\nlogcat.

\n

So what has happened is that the user really is logged out of\nthat Facebook session (the OAuth 2.0 token is no longer valid), but\nTitanium doesn't know about it, so the login button is screwed up\nand showing \"Logout\" instead of \"Connect with Facebook\".

\n

I think what's happening here is that the relevant Titanium code\nto clear the saved session info (saved as a private entry in the\nAndroid Shared Preferences store) does not run until an\nAsynchronous call to Facebook's logout API has returned. By the\ntime that Async call is finished, there are no listeners available\nany more (the user has backed out of the app, the root activity has\nbeen destroyed, etc.)

\n

What we need to do is destroy the session info right when\nTi.Facebook.logout() is called, rather than wait for a\nreturn from FB's logout API call. After all, if an app developer\nhas called .logout(), he wants that session destroyed,\nso why wait? This way the destruction of the session occurs\nsynchronously within the destroy thread.

{html}", "attachment": [], "flagged": false, "summary": "Android: Facebook.logout called from activity destroy event doesn't (always) succeed in clearing saved session info", "creator": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "comment": { "comments": [ { "id": "129895", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "{html}

Commit: \nhttps://github.com/appcelerator/titanium_mobile/commit/74e40cd99a92...

\n

With this change, if you run an app with the above app.js and\nfollow the same steps as described above, when you back out of the\napp now it'll both logout the FB session \"officially\" (i.e, via the\nFB API call) and destroy the session info stored\nby Titanium. When you go back in, the button will say \"Connect with\nFacebook\" (i.e., you'll show as being logged out, which is\ncorrect.)

{html}", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2011-04-15T03:35:02.000+0000", "updated": "2011-04-15T03:35:02.000+0000" }, { "id": "129896", "author": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "body": "{html}

Verified emulator 2.2

{html}", "updateAuthor": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "created": "2011-04-15T03:35:02.000+0000", "updated": "2011-04-15T03:35:02.000+0000" }, { "id": "129897", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "{html}

(from [74e40cd99a92efa3d7e81fcee452b06347a1fad4])\n[#3025 state:fixed-in-qa] destroy fb session info\nimmediately when logout called \nhttps://github.com/appcelerator/titanium_mobile/commit/74e40cd99a92...

{html}", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2011-04-15T03:35:03.000+0000", "updated": "2011-04-15T03:35:03.000+0000" }, { "id": "129898", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "{html}

That was the agent setting it back to fixed-in-qa. It's still\nresolved.

{html}", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2011-04-15T03:35:03.000+0000", "updated": "2011-04-15T03:35:03.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }