Question:
I'm using Xamarin to try to login with facebook, I've generated the Hash and the appID. (Apparently this is correct, as previously the app returned a msg saying that the HASH was invalid). Here is my activity code:
protected override void OnResume()
{
base.OnResume();
// Logs 'install' and 'app activate' App Events.
AppEventsLogger.ActivateApp(this);
}
/// <summary>
/// Register events logs of the facebook
/// </summary>
protected override void OnPause()
{
base.OnPause();
AppEventsLogger.DeactivateApp(this);
}
public override View OnCreateView(View parent, string name, Context context, IAttributeSet attrs)
{
return base.OnCreateView(parent, name, context, attrs);
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
FacebookSdk.SdkInitialize(this.ApplicationContext);
SetContentView(Resource.Layout.splash);
var callbackmanage = CallbackManagerFactory.Create();
LoginButton loginbutton = (LoginButton) base.FindViewById(Resource.Id.login_button);
var fcb = new facebookCallBack();
loginbutton.RegisterCallback(callbackmanage,fcb);
}
private class facebookCallBack : IFacebookCallback
{
public IntPtr Handle
{
get
{
return new IntPtr();
}
}
public void Dispose()
{
}
public void OnCancel()
{
}
public void OnError(FacebookException p0)
{
}
public void OnSuccess(Java.Lang.Object p0)
{
}
}
It turns out that now when I click the login button, nothing happens. It does not give any error messages, nor does it enter callback methods ( OnError
, OnPause
etc), it gives absolutely nothing.
That way I get lost. Can anyone help?
Answer:
You need at least one line of code within the method for the breakpoint to enter. Put a log line and put the breakpoint on the log line.
private class facebookCallBack : IFacebookCallback
{
public IntPtr Handle
{
get
{
return new IntPtr();
}
}
public void Dispose()
{
Console.WriteLine("Teste Dispose");
}
public void OnCancel()
{
Console.WriteLine("Teste OnCancel");
}
public void OnError(FacebookException p0)
{
Console.WriteLine("Teste OnError");
}
public void OnSuccess(Java.Lang.Object p0)
{
Console.WriteLine("Teste OnSuccess");
}
}
Try…
Replace AppEventsLogger.ActivateApp(this); by AppEventsLogger.ActivateApp(getApplication()); and put that line in void OnCreate .
Move the AppEventsLogger.DeactivateApp(this); for void OnDestroy .
If a feedback works.