{ "id": "161621", "key": "MOD-2270", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10034", "key": "MOD", "name": "Appcelerator Modules", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2016-07-11T13:19:42.000+0000", "created": "2016-07-08T15:53:26.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "facebook", "module" ], "versions": [], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2016-07-20T12:08:09.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": "14521", "name": "Facebook" } ], "description": "I am trying to to receive email of user logged in via Facebook. On iOS it reuturns me data without email.\r\n\r\nImportant:\r\n*This is not account problem (it returns email on Android) nor module configuration error (I can log in/log out and retreive other data)*\r\n\r\nh3. Steps to reproduce\r\n\r\n{code}\r\nvar viewClick = function() {\r\n fb.logout();\r\n fb.initialize(); \r\n fb.authorize();\r\n};\r\n\r\nvar facebookLogged = function(e) {\r\n Ti.API.info('results From Event: ' + JSON.stringify(e))\r\n fb.requestWithGraphPath(\"me?fields=name,email,first_name,last_name\", {}, 'GET', function(result) {\r\n // fb.requestWithGraphPath(\"me\", { fields: \"name,email,first_name,last_name\"}, 'GET', function(result) {\r\n Ti.API.info('results From Graph API: ' + JSON.stringify(result))\r\n var data = JSON.parse(result.result);\r\n Ti.API.info(\"-- email: \" + data.email);\r\n });\r\n};\r\n\r\n\r\nvar window = Ti.UI.createWindow({exitOnClose: true, navBarHidden: true, fullscreen: true, orientationModes: [\r\n Ti.UI.PORTRAIT,\r\n Ti.UI.UPSIDE_PORTRAIT, \r\n ],\r\n backgroundColor: '#f0f2f2'\r\n}); \r\n\r\nvar fb = require('facebook');\r\n\r\nif(Ti.Platform.osname === 'android') {\r\n\r\n window.fbProxy = fb.createActivityWorker({lifecycleContainer: window});\r\n}\r\n\r\n //fb.setLoginBehavior(fb.LOGIN_BEHAVIOR_NATIVE);\r\nfb.permissions = ['email'];\r\n\r\nwindow.open();\r\n\r\n\r\nvar view = Ti.UI.createView({\r\n height: 200,\r\n width: 200,\r\n backgroundColor: 'red'\r\n}); \r\n\r\nview.addEventListener('click', viewClick);\r\n\r\nwindow.add(view);\r\nfb.addEventListener('login', facebookLogged);\r\n{code}\r\n\r\n\r\nResults are:\r\n\r\n{code}\r\nresults From Event: {\"success\":true,\"code\":0,\"data\":\"{\\\"firstName\\\":\\\"Eren\\\",\\\"lastName\\\":\\\"Kars\\\",\\\"userID\\\":\\\"1498651573764560\\\",\\\"middleName\\\":\\\"\\\",\\\"name\\\":\\\"Eren Kars\\\",\\\"linkURL\\\":\\\"https:\\\\/\\\\/www.facebook.com\\\\/app_scoped_user_id\\\\/1498651573764560\\\\/\\\"}\",\"uid\":\"1498651573764560\",\"cancelled\":false,\"bubbles\":true,\"type\":\"login\",\"source\":{\"id\":\"facebook\"},\"cancelBubble\":false}\r\n\r\nresults From Graph API: {\"result\":\"{\\\"id\\\":\\\"1498651573764560\\\",\\\"last_name\\\":\\\"Kars\\\",\\\"name\\\":\\\"Eren Kars\\\",\\\"first_name\\\":\\\"Eren\\\"}\",\"success\":true,\"path\":\"me?fields=name,email,first_name,last_name\"}\r\n\r\n-- email: undefined\r\n\r\n{code}\r\n\r\n\r\nThere is no problem with configuration/module because:\r\n\r\n- I made it working on Android (it returns email),\r\n- It works fine with logging in (both on Android/iOS),\r\n- It returns all the fields except email and gives no errors with Graph API.\r\n\r\n", "attachment": [], "flagged": false, "summary": "Appcelerator Titanium Facebook request doesn't return email on iOS", "creator": { "name": "CREATIVE KAIZEN", "key": "creative kaizen", "displayName": "CREATIVE KAIZEN", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "CREATIVE KAIZEN", "key": "creative kaizen", "displayName": "CREATIVE KAIZEN", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Appcelerator Studio, build: 4.6.0.201605201934\r\nSDK: 5.3.1GA,\r\nMacOSX\r\nfacebook: 5.2.0", "comment": { "comments": [ { "id": "390198", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey there,\r\n\r\ndoes the query work in the Graph Explorer? I'm wondering why it does work on Android but not iOS. Thanks!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-07-08T21:17:34.000+0000", "updated": "2016-07-08T21:17:34.000+0000" }, { "id": "390216", "author": { "name": "CREATIVE KAIZEN", "key": "creative kaizen", "displayName": "CREATIVE KAIZEN", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hello Hans,\r\nYes it does. If it would not work there than it would not work on Android either.\r\nRegards\r\n", "updateAuthor": { "name": "CREATIVE KAIZEN", "key": "creative kaizen", "displayName": "CREATIVE KAIZEN", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-07-09T11:57:46.000+0000", "updated": "2016-07-09T11:57:46.000+0000" }, { "id": "390270", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Ok, so after reading [this StackOverflow|http://stackoverflow.com/questions/29323244/facebook-ios-sdk-4-0how-to-get-user-email-address-from-fbsdkprofile], such parameters need to be passed in the {{parameters}} object that is represented by the second argument here. So can you try the following:\r\n\r\n{code:javascript}\r\nfb.requestWithGraphPath(\"me\", {\"fields\": \"name,email,first_name,last_name\"}, 'GET', function(result) {\r\n Ti.API.info('results From Graph API: ' + JSON.stringify(result))\r\n var data = JSON.parse(result.result);\r\n Ti.API.info(\"-- email: \" + data.email);\r\n });\r\n{code}\r\n\r\nOf course it should behave the same on Android and iOS, but maybe the Android SDK still supports the other way for backwards-compatibility. Ultimately, I think the above method is the proper solution and should work, since we \"only\" delegate the parameters to the native method. Give it a try, thanks!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-07-11T08:18:57.000+0000", "updated": "2016-07-11T08:18:57.000+0000" }, { "id": "390285", "author": { "name": "CREATIVE KAIZEN", "key": "creative kaizen", "displayName": "CREATIVE KAIZEN", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hello Hans,\r\n\r\nOn Android only this approach works (and it is in contrary to documentation):\r\n{code}\r\nfb.requestWithGraphPath(\"me\", {\"fields\": \"name,email,first_name,last_name\"}, 'GET', function(result) {\r\n{code}\r\n\r\nOn iOS none of these two approaches returns email. I tried both (you can check my commented line). If I try your code in return I get:\r\n{code}\r\n[INFO] : results From Event: {\"success\":true,\"code\":0,\"data\":\"{\\\"firstName\\\":\\\"Eren\\\",\\\"lastName\\\":\\\"Kars\\\",\\\"userID\\\":\\\"1498651573764560\\\",\\\"middleName\\\":\\\"\\\",\\\"name\\\":\\\"Eren Kars\\\",\\\"linkURL\\\":\\\"https:\\\\/\\\\/www.facebook.com\\\\/app_scoped_user_id\\\\/1498651573764560\\\\/\\\"}\",\"uid\":\"1498651573764560\",\"cancelled\":false,\"bubbles\":true,\"type\":\"login\",\"source\":{\"id\":\"facebook\"},\"cancelBubble\":false}\r\n[INFO] : results From Graph API: {\"result\":\"{\\\"id\\\":\\\"1498651573764560\\\",\\\"last_name\\\":\\\"Kars\\\",\\\"name\\\":\\\"Eren Kars\\\",\\\"first_name\\\":\\\"Eren\\\"}\",\"success\":true,\"path\":\"me\"}\r\n[INFO] : -- email: undefined\r\n{code}\r\n\r\n\r\n", "updateAuthor": { "name": "CREATIVE KAIZEN", "key": "creative kaizen", "displayName": "CREATIVE KAIZEN", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-07-11T12:22:36.000+0000", "updated": "2016-07-11T12:22:36.000+0000" }, { "id": "390290", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "I just tested it myself, using the below demo-code:\r\n{code:javascript}\r\nvar fb = require(\"facebook\");\r\n\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor : \"#fff\"\r\n}); \r\n\r\nvar btn = Ti.UI.createButton({\r\n title : \"Do Graph Request\"\r\n});\r\n\r\nbtn.addEventListener(\"click\", function() {\r\n fb.logout();\r\n\r\n fb.permissions = ['email'];\r\n fb.initialize(); \r\n fb.authorize();\r\n});\r\n\r\nfb.addEventListener('login', function(e) {\r\n fb.requestWithGraphPath(\"me\", {\r\n \"fields\": \"name,email,first_name,last_name\"\r\n }, 'GET', function(result) {\r\n Ti.API.info('results From Graph API: ' + JSON.stringify(result))\r\n var data = JSON.parse(result.result);\r\n Ti.API.info(\"-- email: \" + data.email);\r\n });\r\n});\r\n\r\nwin.add(btn);\r\nwin.open();\r\n{code}\r\n\r\nResult:\r\n{code}\r\n[INFO] results From Graph API: {\"result\":\"{\\\"email\\\":\\\"xxxxxx\\\",\\\"id\\\":\\\"272367196277712\\\",\\\"last_name\\\":\\\"App\\\",\\\"name\\\":\\\"Demo App\\\",\\\"first_name\\\":\\\"Demo\\\"}\",\"success\":true,\"path\":\"me\"}\r\n[INFO] -- email: xxxxxx\r\n{code}\r\n\r\nSo I am pretty sure that either your Facebook application is configured incorrectly for iOS, your tiapp.xml is missing some of the keys described [here|https://github.com/appcelerator-modules/ti.facebook] or your application logic overrides the permissions from somewhere else.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-07-11T13:19:10.000+0000", "updated": "2016-07-11T13:19:10.000+0000" }, { "id": "390291", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Closing for now, since I cannot reproduce it with using the provided test-case. ", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-07-11T13:19:42.000+0000", "updated": "2016-07-11T13:19:42.000+0000" }, { "id": "391085", "author": { "name": "CREATIVE KAIZEN", "key": "creative kaizen", "displayName": "CREATIVE KAIZEN", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Adding:\r\n{code}\r\nLSApplicationQueriesSchemes\r\n \r\n fbapi\r\n fbapi20130214\r\n fbapi20130410\r\n fbapi20130702\r\n fbapi20131010\r\n fbapi20131219\r\n fbapi20140410\r\n fbapi20140116\r\n fbapi20150313\r\n fbapi20150629\r\n fbapi20160328\r\n fbauth\r\n fbauth2\r\n fb-messenger-api20140430\r\n \r\n{code}\r\n\r\nPreviosly I had shorter version of strings and it was the cause.\r\n\r\nSorry for trouble.", "updateAuthor": { "name": "CREATIVE KAIZEN", "key": "creative kaizen", "displayName": "CREATIVE KAIZEN", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-07-20T12:08:09.000+0000", "updated": "2016-07-20T12:08:09.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }