I’m having troubles using the facebook binding from here ( https://github.com/mono/monotouch-bindings/tree/master/facebook ) and the problem is that the authorize ( login ) function doesn’t work on the device. On the simulator it’s working perfect, but from the device instead of the webbrowser login window it launches the official facebook app ( installed on the phone ).
The same thing happens with the sample provided with the binding.
Any ideeas how can I use the browser to login ( if I unninstall the official facebook app it works ok on the device also ) instead of the facebook app?
The code I use:
class SessionDelegate : FBSessionDelegate
{
AppDelegate container;
NSAction onLogin;
public NSAction OnLogin {
get {
return this.onLogin;
}
set {
onLogin = value;
}
}
public SessionDelegate (AppDelegate container)
{
this.container = container;
}
public override void DidNotLogin (bool cancelled)
{
Console.WriteLine("did not login");
//container.SaveAuthorization ();
if( OnLogin != null ) OnLogin.Invoke();
}
public override void DidLogin ()
{
Console.WriteLine("login !");
container.SaveAuthorization ();
if( OnLogin != null ) OnLogin.Invoke();
}
public override void DidLogout ()
{
Console.WriteLine("logout !");
container.ClearAuthorization();
}
}
And:
var sessionDelegate = new SessionDelegate (this);
facebook = new Facebook (LocalSettings.FacebookAppId, sessionDelegate);
var defaults = NSUserDefaults.StandardUserDefaults;
if (defaults ["FBAccessTokenKey"] != null && defaults ["FBExpirationDateKey"] != null)
{
facebook.AccessToken = defaults ["FBAccessTokenKey"] as NSString;
facebook.ExpirationDate = defaults ["FBExpirationDateKey"] as NSDate;
}
and for login:
facebook.Authorize(new string [] { "email", "publish_stream", "read_friendlists", "user_photos" });
Okay, so I found the answer myself. The problem was in the facebook developer app settings, the iOS Bundle ID didn’t was the same with the one in monodevelop identifier 🙂