Reputation: 795
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" });
Upvotes: 4
Views: 1584
Reputation: 60023
FWIW: you'll get the same error if you are in the sandbox and try to logon with a real user.
Upvotes: 0
Reputation: 795
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 :)
Upvotes: 3
Reputation: 3077
This functionality is the developer's intend. First I don't understand why you don't want this and Second this is a open-source library. you can walk through the code and find the piece of code that makes it. Then change it to what you want. I am now searching for this in this library. As long as I got the answer I reply it. But my guess is that they have used UIApplication.SharedApplication.* to open up Facebook app if it is available.
Sincerely yours, Peyman Mortazavi
Upvotes: 0