Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LogOut from Facebook using childBrowser and PhoneGap in IPhone

Tags:

iphone

cordova

I'm working on PhoneGap and have a FBConnect. Using childBrowser and the blog'http://www.pushittolive.com/post/1239874936/facebook-login-on-iphone-phonegap', I have logged in to the App. But could not logout from the app. It's autosigned in for each time I login.

Can any one tell me how to logout from the FBConnect using Childbrowsern PhoneGap?

like image 327
bharath gangupalli Avatar asked Feb 04 '11 05:02

bharath gangupalli


Video Answer


2 Answers

Try this.

Add this function to ChildBrowserCommand.m

-(void) deleteCookies:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options{
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 
    for (NSHTTPCookie *each in [cookieStorage cookies]) {
            [cookieStorage  deleteCookie:each];
    }
}

Add this to Childbrowser.js

ChildBrowser.prototype.LogOut = function()
{
     PhoneGap.exec("ChildBrowserCommand.deleteCookies");
}

Add this to FBConnect.js

FBConnect.prototype.Logout = function()
{
   window.plugins.childBrowser.LogOut();    
}

At your page add this code to logout button on click

function Logout()
{
  var fb=FBConnect.install();
  fb.Logout();
}

Enjoy.

like image 63
Mohamed el-Desouky Avatar answered Sep 30 '22 18:09

Mohamed el-Desouky


Best way to tell facebook to logout.

It can Be done by opening below url in child browser:

"https://www.facebook.com/logout.php?next="+your_site_url_registered _on_fb+"&access_token="+accessToken
like image 28
Mehul Gayate Avatar answered Sep 30 '22 17:09

Mehul Gayate