UserID0908
UserID0908

Reputation: 108

Facebook logout programmatically in Xamarin ios in Visual Studio

I have an application in IOS in which there is a Facebook Login Button. when ever user clicks this Facebook login button My app redirects the user to the Facebook App installed in my device. So I want to logout the user from the application as soon as he leaves the facebook app and comes to my app. i redirect the user to the facebook app using

NSUrl url = NSUrl.FromString("fb://profile/<id>");
UIApplication.SharedApplication.OpenUrl(url); 

Upvotes: 0

Views: 535

Answers (2)

BR75
BR75

Reputation: 667

Are you using the Xamarin Facebook SDK? If yes you can do this to log out:

new LoginManager().LogOut();

Upvotes: 1

Kevin Li
Kevin Li

Reputation: 2258

I found the Facebook login documentation. As the documentation described, I think you have added the CFBundleURLTypes, like this:

<key>CFBundleURLTypes</key>
<array>
  <dict>
  <key>CFBundleURLSchemes</key>
  <array>
    <string>fb[APP_ID]</string>
  </array>
  </dict>
</array>

It means that Facebook will trigger the openURL to return back to your app via the URLScheme you have set here.

So, you can override OpenUrl(UIApplication app, NSUrl url, NSDictionary options) in AppDelegate.cs, and the parameters url or options contain the information related to Facebook. So, you can identify the resource.

public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
    {
        Console.WriteLine(url);
        Console.WriteLine(options);

        return true;
    }

According to this, you can do the action you want when return back from Facebook.

Upvotes: 1

Related Questions