Facebook api with monotouch

I am having problems using facebook binding from here ( https://github.com/mono/monotouch-bindings/tree/master/facebook ) and the problem is that the authorization (login) function doesnโ€™t work on the device. It works fine on the simulator, but the official facebook application (installed on the phone) is launched from the device instead of the login window to the webbrowser.

The same thing happens with a reference sample.

Any ideas how I can use a browser to log into the system (if I do not delete the official facebook application, it works fine on the device as well) instead of the facebook application?

The code I'm using is:

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 to enter:

 facebook.Authorize(new string [] { "email", "publish_stream", "read_friendlists", "user_photos" }); 
+4
source share
3 answers

Ok, so I found the answer myself. The problem was with the application settings for facebook developers, the iOS package identifier was not the same as the monodevelop identifier :)

+3
source

This functionality is intended for developers. At first I donโ€™t understand why you do not want this, and secondly, it is an open source library. you can go through the code and find a piece of code that does this. Then change it to what you want. Now I am looking for this in this library. While I received the answer, I answer. But I guess they used UIApplication.SharedApplication. * To open the Facebook application, if available.

Sincerely yours, Peyman Mortazavi

0
source

FWIW: You will get the same error if you are in the sandbox and try to log in with a real user.

0
source

Source: https://habr.com/ru/post/1404014/


All Articles