Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2792] iOS: Facebook permissions return false positives

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2016-08-27T12:56:11.000+0000
Affected Version/sRelease 1.6.0
Fix Version/sBacklog
ComponentsiOS
Labelsdefect, facebook, ios, reported-1.6.0, rplist
ReporterDawson Toth
AssigneeIngo Muschenetz
Created2011-04-15T03:29:41.000+0000
Updated2017-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

FileDateSize
facebookrequestpermissionlog.rtf2011-04-15T03:29:42.000+00003481
fbconnect_perm.patch2011-04-15T03:29:42.000+0000640

Comments

  1. Jesus H. Christ 2011-04-15

    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:

       if ([url.resourceSpecifier isEqualToString:@"cancel"]) {
       

    TO:

       if ([[url.resourceSpecifier substringToIndex:6] isEqualToString:@"cancel"]) {
       

    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.

  2. Anthony Roldan 2011-04-15

    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.

  3. Blain Hamon 2011-10-14

    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.
  4. Hans Knöchel 2016-08-27

    Fixed with Ti.Facebook 5.0.0 and later.
  5. Lee Morris 2017-03-20

    Closing ticket as fixed.

JSON Source