freshplanet / ANE-Facebook

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

Problem with logout #132

Closed Rikly86 closed 7 years ago

Rikly86 commented 10 years ago

Hi! I have problem with logout - the function 'closeSessionAndClearTokenInformation' clear session, but i dont see faceboook login page.. My device HTC Disire s, android 2.3. Here some code:

    public function FacebookHelper2(){
        super();    
        if(Facebook.isSupported){
            _fb = Facebook.getInstance();
            _fb.init(APP_ID);

            if(_fb.isSessionOpen){
                loginSuccess();
                _fb.dialog("oauth", null, handler_dialog, true);
            }
        }
        FacebookMobile.init(APP_ID, onFacebookInit);
    }

    private function onFacebookInit(result:Object, fail:Object):void{

    }

    public function login():void{
        if(!_fb.isSessionOpen){
            NativeDialogs.getInstance().showAlert('Session NOT EXIST');
            _fb.init(APP_ID);
            _fb.openSessionWithReadPermissions(READ_PERMISSIONS, handler_openSessionWithPermissions,false);
        }else{
            NativeDialogs.getInstance().showAlert('Session EXIST');
            _fb.requestWithGraphPath("/me", null, URLRequestMethod.GET, onLogin);
        }
    }

    private function handler_openSessionWithPermissions($success:Boolean, $userCancelled:Boolean, $error:String = null):void{
        if($success){
            loginSuccess();
        }

        //extend post permissions
        //_fb.reauthorizeSessionWithPublishPermissions(POST_PERMISSIONS);
    }

    private function loginSuccess():void{
        _fb.requestWithGraphPath("/me", null, URLRequestMethod.GET, onLogin);
    }

    private function onLogin(response:Object):void{

        dispatchEvent(new Event(EVENT_LOGGINED,false,response));
    }

    public function postOnWall(params:Object):void{
        _fb.requestWithGraphPath("/me/feed", params, "POST",onPostOnWall);
    }

    private function onPostOnWall(response:Object):void{
        dispatchEvent(new Event(EVENT_POST_ON_WALL,false,response));
    }

    public function logout():void{
        //FacebookMobile.logout(handleLogout,'https://m.facebook.com/dialog/permissions.request?app_id=' + APP_ID + '&display=touch&type=user_agent&perms=publish_stream&fbconnect=1');
        //Facebook.getInstance().closeSessionAndClearTokenInformation();
        _fb.closeSessionAndClearTokenInformation();
        //setTimeout(logout,500);
    }

Can someone help me, please?