{ "id": "134843", "key": "TIMOB-17614", "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": [], "resolution": null, "resolutiondate": null, "created": "2014-08-17T11:56:55.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [ "TCSupport", "android", "facebook", "login" ], "versions": [ { "id": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" } ], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:04:00.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h4. Problem Description\r\nI recently discovered an issue on Android when logging into Facebook to use the user-data like name & id. Therefor the login callback returns a \"data\" object, which needs to be parsed manually on Android, but in iOS you don't need to do anything extra. \r\n \r\nh4. Steps to reproduce\r\n\r\n- Create a simple project.\r\n- Update app.js with:\r\n{code} \r\nvar fb = require(\"facebook\");\r\nvar win = Ti.UI.createWindow({backgroundColor: \"#fff\"});\r\nvar btn = Ti.UI.createButton({title: \"Facebook-Login\"});\r\n \r\nbtn.addEventListener(\"click\", doLogin);\r\nfb.addEventListener(\"login\", debugLogin);\r\n \r\nfunction doLogin() {\r\n fb.appid = \"***************\";\r\n fb.permissions = [\"publish_stream\"];\r\n fb.forceDialogAuth = false;\r\n fb.authorize();\r\n}\r\n \r\nfunction debugLogin(e) {\r\n Ti.API.info(JSON.stringify(e.data));\r\n alert(e.data.name); // Doesn't work for android\r\n // var t =JSON.parse(e.data); // Does work for android.\r\n // alert(t.name); // Does work for android.\r\n}\r\n\r\nwin.add(btn);\r\nwin.open();\r\n{code}\r\n\r\n- Add facebook module in tiapp.xml\r\n- Run on android device\r\n\r\n\r\nh4. Extra info\r\nThe difference in the callbacks are here. \r\niOS: https://gist.github.com/hansknoechel/9e63d4b683bd72cc29bd\r\nAndroid: https://gist.github.com/hansknoechel/f0f3280fda26f98d52c0\r\n\r\nThe bug was also discussed 2 years ago in the Q&A: https://developer.appcelerator.com/question/135341/titaniumfacebook-login-callback---cant-access-user-data-on-android-device\r\n\r\nh4. Workaround\r\nThe bug can be \"fixed\" by using a conditional statement like:\r\n{code}\r\nvar data = (OS_ANDROID) ? JSON.parse(e.data) : e.data;\r\n{code}\r\nBut a consistent behaviour is clearly the better way.", "attachment": [], "flagged": false, "summary": "Android: Facebook-Login-Callback needs JSON.parse (parity)", "creator": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "environment": " Titanium SDK: 3.3.0.GA\r\n Titanium CLI: 3.3.0\r\n OS X Version: 10.9.3\r\n Android: 4.4.3\r\n iOS: 7.1.2", "comment": { "comments": [], "maxResults": 2, "total": 2, "startAt": 0 } } }