我正在使用 Xamarin.Auth 在我的应用程序(android/iOS)中使用 facebook 登录,一切顺利,但是成功登录后,facebook 个人资料正在打开并且不会返回到我的应用程序。我想在不显示 facebook 个人资料的情况下重定向到我的应用主页。我正在关注本教程,但没有取得任何成功。我想我没有给出我的应用程序的正确网址。请给我建议。提前感谢您的帮助。
这是我的 loginPageRenderer 代码:
[assembly: ExportRenderer (typeof (FBLoginPage), typeof (LoginPageRendrerr))]
namespace FFirst_app.Droid
{
public class LoginPageRendrerr : PageRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
{
base.OnElementChanged(e);
// this is a ViewGroup - so should be able to load an AXML file and FindView<>
var activity = this.Context as Activity;
var auth = new OAuth2Authenticator (
clientId: "7b745e26dbb64e1a3a3bf6bfd33165bc", // your OAuth2 client id
scope: "basic", // the scopes for the particular API you're accessing, delimited by "+" symbols
authorizeUrl: new Uri("https://apps.facebook.com/myappppppp"),//("https://api.instagram.com/oauth/authorize/"), // the auth URL for the service
redirectUrl: new Uri ("http://www.facebook.com/connect/login_success.html")); // the redirect URL for the service
auth.Completed += (sender, eventArgs) => {
if (eventArgs.IsAuthenticated)
{
App.SuccessfulLoginAction.Invoke();
// Use eventArgs.Account to do wonderful things
App.SaveToken(eventArgs.Account.Properties["access_token"]);
string sessionToken = App.Token; // /* Authenticate the user with Facebook and fetch a session token */;
DateTime expiration = DateTime.Today; ///* The expiration time for the session token */;
string facebookId = Constants.FBAppId;
ParseFacebookUtils.LogInAsync (facebookId, sessionToken, expiration);
} else {
// The user cancelled
}
};
activity.StartActivity (auth.GetUI(activity));
}
}
}