freshplanet / ANE-Facebook

Air Native Extension (iOS and Android) for the Facebook mobile SDK
Apache License 2.0
221 stars 123 forks source link

iOS6 permissions request returning userCancelled as true #139

Closed eric-holmes closed 10 years ago

eric-holmes commented 10 years ago

The ANE is working great on iOS7. I borrowed a coworkers iPhone 4 with iOS 6.1.3.

When performing the openSessionWithPublishPermissions call, the callback receives userCancelled as true, even though I am clicking "Okay". The Don't Allow option is properly setting the APPLICATION_TURNED_OFF error.

Is this a known issue? Is there a way to force webview authentication as a quickfix? I already have a SystemProperties ANE which allows me to detect the iOS version.

kobydo commented 10 years ago

Hi, This is a known issue. You need to start with openSession without write permissions, and then extend the permissions to WithPublishPermissions.

Also, make sure your Facebook iOS settings are all Kosher.

Koby.

eric-holmes commented 10 years ago

Interesting. So essentially, in the non-write permissions callback, I would then open the publish permissions session? Would that not force the app to switch to Facebook twice?

In either way, setting systemFlow to false actually fixed the problem. I will attempt your advice and see if that works fine, however.

Thanks!

kobydo commented 10 years ago

Sure, I'd be happy if you let me know if it works, since this is a more elegant solutuion.

Koby.

On Thu, Apr 17, 2014 at 3:48 PM, Eric Holmes notifications@github.comwrote:

Interesting. So essentially, in the non-write permissions callback, I would then open the publish permissions session? Would that not force the app to switch to Facebook twice?

In either way, setting systemFlow to false actually fixed the problem. I will attempt your advice and see if that works fine, however.

Thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/freshplanet/ANE-Facebook/issues/139#issuecomment-40709995 .

Koby Douek

Webcand LTD. Givatayiim, Israel 53211 Mobile: +972-52-8907709 http://webcand.com

kobydo commented 10 years ago

Where did you change SysyemFlow to false ? Where is this property ?

Koby

On Thu, Apr 17, 2014 at 3:48 PM, Eric Holmes notifications@github.comwrote:

Interesting. So essentially, in the non-write permissions callback, I would then open the publish permissions session? Would that not force the app to switch to Facebook twice?

In either way, setting systemFlow to false actually fixed the problem. I will attempt your advice and see if that works fine, however.

Thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/freshplanet/ANE-Facebook/issues/139#issuecomment-40709995 .

Koby Douek

Webcand LTD. Givatayiim, Israel 53211 Mobile: +972-52-8907709 http://webcand.com

eric-holmes commented 10 years ago

facebook.openSessionWithPublishPermissions(['publish_actions'], fbPublishCallback, false);

kobydo commented 10 years ago

And this works fine ?

On Thu, Apr 17, 2014 at 4:02 PM, Eric Holmes notifications@github.comwrote:

.openSessionWithPublishPermissions(['publish_actions'], fbPublishCallback, false);

— Reply to this email directly or view it on GitHubhttps://github.com/freshplanet/ANE-Facebook/issues/139#issuecomment-40711138 .

Koby Douek

Webcand LTD. Givatayiim, Israel 53211 Mobile: +972-52-8907709 http://webcand.com

eric-holmes commented 10 years ago

It does. The issue was only occuring on iOS6.1.3, not iOS 7. Setting systemFlow to false had no effect on iOS7 and fixed iOS6.

I just testing this approach - and it confirmed my belief. Let me know if I did it the way you had in mind. The App heads over to the Facebook App (iOS7), approves Read permissions, jumps back to my app, then jumps back to Facebook again for publish permissions. Where before just using openSessionWithPublishPermissions would prompt for read, then publish, in the same interaction with Facebook. I will test this on iOS6 right now as well.

    public function fbLogin():void {
        facebook.openSessionWithReadPermissions(['basic_info'],fbReadCallback);
    }

    public function fbReadCallback(success:Boolean, userCancelled:Boolean, error:String = null):void {
        if (success) {
            facebook.openSessionWithPublishPermissions(['publish_actions'], fbPublishCallback);
        }
    }

    public function fbPublishCallback(success:Boolean, userCancelled:Boolean, error:String = null):void {
        trace(success, userCancelled, error);
        if (success) {
            this.isFacebookAuthorized = true;
            this.dispatchEvent(new Event(FB_LOGIN));
        }
    }
eric-holmes commented 10 years ago

The working line is

 facebook.openSessionWithPublishPermissions(['publish_actions'], fbPublishCallback, false);
eric-holmes commented 10 years ago

So, after testing the above code on iOS6, I see that it's exactly what I would want, simply because it comes up with popups, not leaving the app, where in iOS7 it actually sends you to the Facebook App directly.

I guess the only solution is to detect which OS we are dealing with, and use 2 different processes?

    public function fbLogin():void {
        if (isIOS6) { // psuedo code
            facebook.openSessionWithReadPermissions(['basic_info'],fbReadCallback);
        } else {
            facebook.openSessionWithPublishPermissions(['publish_actions'], fbPublishCallback);
        }
    }

    public function fbReadCallback(success:Boolean, userCancelled:Boolean, error:String = null):void {
        if (success) {
            facebook.openSessionWithPublishPermissions(['publish_actions'], fbPublishCallback);
        }
    }

    public function fbPublishCallback(success:Boolean, userCancelled:Boolean, error:String = null):void {
        trace(success, userCancelled, error);
        if (success) {
            this.isFacebookAuthorized = true;
            this.dispatchEvent(new Event(FB_LOGIN));
        }
    }