[TIMOB-2792] iOS: Facebook permissions return false positives
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-08-27T12:56:11.000+0000 |
Affected Version/s | Release 1.6.0 |
Fix Version/s | Backlog |
Components | iOS |
Labels | defect, facebook, ios, reported-1.6.0, rplist |
Reporter | Dawson Toth |
Assignee | Ingo Muschenetz |
Created | 2011-04-15T03:29:41.000+0000 |
Updated | 2017-03-20T16:59:32.000+0000 |
Description
Problem
If a user clicks "Don't Allow" when an app asks for additional information, evt.success and hasPermission will still return "true" for this permission, when they should return false. This false positive only occurs in iOS, in my testing.
Sample Code Demonstrating Problem
The following sample code demonstrates the problem.
Use the following steps to reproduce in sample code:
1. Click "Connect with Facebook"
2. Sign in
3. Click "Don't Allow"
/**
* Function that logs the user into Facebook, and makes sure they have
* granted us the "user_checkins" permission.
*/
function checkIfUserIsLoggedIntoFacebook() {
// if user hasn't logged in yet, don't do anything
// (they need to click the "Connect with Facebook" button)
if (Titanium.Facebook.isLoggedIn() === false) {
}
// if the user hasn't given us the permissions we want, request them.
else if (!Titanium.Facebook.hasPermission("user_checkins")) {
Titanium.Facebook.requestPermission("user_checkins", function (evt) {
if (evt.success) {
alert('Permission GRANTED');
} else {
alert("Permission DENIED");
}
});
}
// otherwise, we should be good to go
else {
alert('Permission ALREADY GRANTED');
}
}
/**
* Add a login event listener so we can check if we have all the permissions
* we want.
*/
Titanium.Facebook.addEventListener('login', function (evt) {
if (evt.success) {
checkIfUserIsLoggedIntoFacebook();
}
});
// create our window
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
win.add(Ti.Facebook.createLoginButton({
apikey: '645bf1d897d1fa8dc93ed45bc37edc04',
secret: '49d146f85b8429438262380b85f2ebac',
style: 'wide'
}));
win.open();
Tested On
Tested on CI build 1.6.0 from January 8th, 2010.
BROKEN on iPhone Simulator, 4.2
WORKS on Android Simulator APIs 2.2
Associated Helpdesk Ticket
http://developer.appcelerator.com/helpdesk/view/63481">http://developer.appcelerator.com/helpdesk/view/63481
Attachments
File | Date | Size |
---|---|---|
facebookrequestpermissionlog.rtf | 2011-04-15T03:29:42.000+0000 | 3481 |
fbconnect_perm.patch | 2011-04-15T03:29:42.000+0000 | 640 |
The easy fix for this (short of ripping out and replacing the Facebook module with new code, which is ideal) is to change one line in the FBConnect/FBDialog.m (line 391 in Mobile SDK 1.5.1).
The line should change FROM:
TO:
Attached is a patch file that accomplishes that. Again, ideally, the new FBConnect module gets put in place which also includes new permissions and proper resposes to their new API. The current REST API is being deprecated.
Having this broken also affects Titanium.Facebook.requestPermission, and causes it to not pop up a dialog if a user previously declined it.
Jesus H. Christ's patch above fixes that too, though! Thanks, Jesus.
Researching. By the way, isLoggedIn is not and was never a valid function on iOS. Use the property Titanium.Facebook.loggedIn as shown in Kitchen Sink. Similarly, there is no hasPermission, only permissions.
Fixed with Ti.Facebook 5.0.0 and later.
Closing ticket as fixed.