FacebookComponents
FacebookComponents copied to clipboard
Android 12 Update and SDK update
Since it was quite some time since the latest update..
This solves as well issues #210 #236
@thisisthekap Any chance you can have a look at the warnings for the Core package?
for example this one I don't understand
warning BG8A04: Metadata.xml element '<attr path="/api/package[@name='com.facebook']/interface[@name='AccessToken.Companion']/method[@name='setCurrentAccessToken' and count(parameter)=1 and parameter[1][@type='com.facebook.AccessToken']]/parameter[1]" />' matched no nodes.
I think I understand most of it now and I updated the mappings for the "core" project. @Redth Could you have a look or someone else?
@SotoiGhost looks like You are the only one maintaining this repo. Any chance to have a look at my code and questions?
Hi there, are any experts looking into this? Facebook put us on notice if we don't fix Facebook Login issue on Android 12 we are going to be denied service, our plugins rely on your binding. Please update. thx.
I'm trying to build as is from source code but it surprisingly fails, does anyone know what am I missing? bellow are the errors I get: Error: Error(s) occurred when compiling build script: /Users/sungureanu/Developer/FaceBook/Facebook.iOS/build.cake(92,2): error CS0103: The name 'CocoaPodRepoUpdate' does not exist in the current context /Users/sungureanu/Developer/FaceBook/Facebook.iOS/common.cake(71,2): error CS0103: The name 'CocoaPodInstall' does not exist in the current context /Users/sungureanu/Developer/FaceBook/Facebook.iOS/common.cake(142,3): error CS0103: The name 'XCodeBuild' does not exist in the current context /Users/sungureanu/Developer/FaceBook/Facebook.iOS/common.cake(142,18): error CS0246: The type or namespace name 'XCodeBuildSettings' could not be found (are you missing a using directive or an assembly reference?) /Users/sungureanu/Developer/FaceBook/Facebook.iOS/common.cake(183,3): error CS0103: The name 'XCodeBuild' does not exist in the current context /Users/sungureanu/Developer/FaceBook/Facebook.iOS/common.cake(183,19): error CS0246: The type or namespace name 'XCodeBuildSettings' could not be found (are you missing a using directive or an assembly reference?) Error: .NET CLI: Process returned an error (exit code 1).
@sereoja that's why I worked quite a bit to update to the Android 12 and SDK update, as there is a breaking bug in the SDK 11. Unfortunately @SotoiGhost is only working on iOS and no one else with rights to this project seems to look into this.
In one of my projects I disabled Android 12 Facebook login and sign up, so that Facebook allows my apps to use FB login on other devices...
@SotoiGhost could you post the Pipeline logs here so I can figure out why they are failing?
@mos379 when running it locally I get this for Android: 4 Error(s)
Time Elapsed 00:00:04.20 An error occurred when executing task 'libs'.
"/Users/sungureanu/Downloads/temp/Facebook.Android/source/Xamarin.Facebook.sln" (Build target) (1:2) -> "/Users/sungureanu/Downloads/temp/Facebook.Android/source/facebook-common/facebook-common.csproj" (default target) (3:14) -> "/Users/sungureanu/Downloads/temp/Facebook.Android/source/facebook-common/facebook-common.csproj" (Build target) (3:16) -> (CoreCompile target) -> /Users/sungureanu/Downloads/temp/Facebook.Android/source/facebook-common/obj/Release/monoandroid12.0/generated/src/Xamarin.Facebook.Share.Widget.ShareDialog.cs(10,91): error CS0535: 'ShareDialog' does not implement interface member 'ISharer.ShouldFailOnDataError' [/Users/sungureanu/Downloads/temp/Facebook.Android/source/facebook-common/facebook-common.csproj] /Users/sungureanu/Downloads/temp/Facebook.Android/source/facebook-common/obj/Release/monoandroid12.0/generated/src/Xamarin.Facebook.Login.NativeAppLoginMethodHandler.cs(265,23): error CS0533: 'NativeAppLoginMethodHandler.TryAuthorize(LoginClient.Request)' hides inherited abstract member 'LoginMethodHandler.TryAuthorize(LoginClient.Request)' [/Users/sungureanu/Downloads/temp/Facebook.Android/source/facebook-common/facebook-common.csproj] /Users/sungureanu/Downloads/temp/Facebook.Android/source/facebook-common/obj/Release/monoandroid12.0/generated/src/Xamarin.Facebook.Login.NativeAppLoginMethodHandler.cs(304,25): error CS0534: 'NativeAppLoginMethodHandlerInvoker' does not implement inherited abstract member 'LoginMethodHandler.TryAuthorize(LoginClient.Request)' [/Users/sungureanu/Downloads/temp/Facebook.Android/source/facebook-common/facebook-common.csproj] /Users/sungureanu/Downloads/temp/Facebook.Android/source/facebook-common/obj/Release/monoandroid12.0/generated/src/Xamarin.Facebook.Login.KatanaProxyLoginMethodHandler.cs(10,30): error CS0534: 'KatanaProxyLoginMethodHandler' does not implement inherited abstract member 'LoginMethodHandler.TryAuthorize(LoginClient.Request)' [/Users/sungureanu/Downloads/temp/Facebook.Android/source/facebook-common/facebook-common.csproj]
@sereoja I get the same errors too. @mos379 any advices on how to build this library locally, while this pull request is open?
@skir @sereoja did you try to build my main or the main of this project?
@mos379 I tried to build your main.
Hi, if you're interested in "Login with Facebook" feature only, you may try using this plugin https://www.nuget.org/packages/Xam.Facebook.Login.Android/ https://www.nuget.org/packages/Xam.Facebook.Core.Android/ https://www.nuget.org/packages/Xam.Facebook.Common.Android/ I've stripped all other facebook features since those were causing build issues and left only Login, and keep in mind the intent is to get us unstuck for now but I encourage to keep updating Xamarin.FacebookComponents to keep this great plugin alive.
The build errors seems to be
/Users/runner/work/1/s/Facebook.Android/source/facebook-common/obj/Release/monoandroid12.0/generated/src/Xamarin.Facebook.Login.NativeAppLoginMethodHandler.cs(265,23): error CS0533: 'NativeAppLoginMethodHandler.TryAuthorize(LoginClient.Request)' hides inherited abstract member 'LoginMethodHandler.TryAuthorize(LoginClient.Request)' [/Users/runner/work/1/s/Facebook.Android/source/facebook-common/facebook-common.csproj] /Users/runner/work/1/s/Facebook.Android/source/facebook-common/obj/Release/monoandroid12.0/generated/src/Xamarin.Facebook.Login.NativeAppLoginMethodHandler.cs(304,25): error CS0534: 'NativeAppLoginMethodHandlerInvoker' does not implement inherited abstract member 'LoginMethodHandler.TryAuthorize(LoginClient.Request)' [/Users/runner/work/1/s/Facebook.Android/source/facebook-common/facebook-common.csproj] /Users/runner/work/1/s/Facebook.Android/source/facebook-common/obj/Release/monoandroid12.0/generated/src/Xamarin.Facebook.Login.KatanaProxyLoginMethodHandler.cs(10,30): error CS0534: 'KatanaProxyLoginMethodHandler' does not implement inherited abstract member 'LoginMethodHandler.TryAuthorize(LoginClient.Request)' [/Users/runner/work/1/s/Facebook.Android/source/facebook-common/facebook-common.csproj] /Users/runner/work/1/s/Facebook.Android/source/facebook-common/obj/Release/monoandroid12.0/generated/src/Xamarin.Facebook.Share.Widget.ShareDialog.cs(10,91): error CS0535: 'ShareDialog' does not implement interface member 'ISharer.ShouldFailOnDataError' [/Users/runner/work/1/s/Facebook.Android/source/facebook-common/facebook-common.csproj]
mos379:main
gh pr checkout 237
Has anyone successfully logged in by installing the following packages? Actually I couldn't log in.
https://www.nuget.org/packages/Xam.Facebook.Login.Android https://www.nuget.org/packages/Xam.Facebook.Core.Android https://www.nuget.org/packages/Xam.Facebook.Common.Android
Is anyone here ? Will this fix be merged one day ? apps have been crashing in prod
@Transatranticism I suceeded in using https://www.nuget.org/packages/Xam.Facebook.Login.Android only for loging users in. I removed the SDK built by Microsoft, and used that one instead. It required a few modifications, but wasn't difficult.
If you only need to support facebook-login perhaps you can try out the WebAuthenticator. Worked out well for me.
https://learn.microsoft.com/en-us/xamarin/essentials/web-authenticator?tabs=android
If you only need to support facebook-login perhaps you can try out the WebAuthenticator. Worked out well for me.
https://learn.microsoft.com/en-us/xamarin/essentials/web-authenticator?tabs=android
As far as I recall this is no longer allowed by FB policies... You have to have native login.
If you only need to support facebook-login perhaps you can try out the WebAuthenticator. Worked out well for me. https://learn.microsoft.com/en-us/xamarin/essentials/web-authenticator?tabs=android
As far as I recall this is no longer allowed by FB policies... You have to have native login.
I know about the Webview limitation but I have tried it out and it seems to be working. The WebAuthentication is apparently using Android CustomTabs.
This is a quite new Ms-response https://learn.microsoft.com/en-us/answers/questions/1068276/xamarin-forms-facebook-login-using-custom-tab.html
CustomTabs mentioned here https://developers.facebook.com/docs/facebook-login/android/deprecating-webviews
Hi, if you're interested in "Login with Facebook" feature only, you may try using this plugin https://www.nuget.org/packages/Xam.Facebook.Login.Android/ https://www.nuget.org/packages/Xam.Facebook.Core.Android/ https://www.nuget.org/packages/Xam.Facebook.Common.Android/ I've stripped all other facebook features since those were causing build issues and left only Login, and keep in mind the intent is to get us unstuck for now but I encourage to keep updating Xamarin.FacebookComponents to keep this great plugin alive.
I can auth with FB using these nugets after removing official one
Hi, if you're interested in "Login with Facebook" feature only, you may try using this plugin https://www.nuget.org/packages/Xam.Facebook.Login.Android/ https://www.nuget.org/packages/Xam.Facebook.Core.Android/ https://www.nuget.org/packages/Xam.Facebook.Common.Android/ I've stripped all other facebook features since those were causing build issues and left only Login, and keep in mind the intent is to get us unstuck for now but I encourage to keep updating Xamarin.FacebookComponents to keep this great plugin alive.
I can auth with FB using these nugets after removing official one
Be sure to add the client token in manifest as well. I was on an older version, but upgrading to this fix worked for me too, and able to log in.
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
Thanks for that @sereoja. I'm using that version and it works perfectly if Facebook app is installed but for some reason it doesn't work when login is completed using webview. Login page is opened and login seems to complete but when it comes back to the app nothing happens because OnActivityResult or ICallbackManager are never called. Also, when webview opens there are some errors like
Rejecting re-init on previously-failed class java.lang.Class<Gg2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/webkit/PacProcessor;
Any ideas?
Thanks for that @sereoja. I'm using that version and it works perfectly if Facebook app is installed but for some reason it doesn't work when login is completed using webview. Login page is opened and login seems to complete but when it comes back to the app nothing happens because OnActivityResult or ICallbackManager are never called. Also, when webview opens there are some errors like
Rejecting re-init on previously-failed class java.lang.Class<Gg2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/webkit/PacProcessor;Any ideas?
Here how I did it, hope it helps:
` private readonly IFacebookClient _facebookService;
in ctr: _facebookService = CrossFacebookClient.Current;
in OnLogin Method: try { if (_facebookService.IsLoggedIn) { _facebookService.Logout(); }
async void userDataDelegate(object sender, FBEventArgs<string> e)
{
if (e == null)
{
return;
}
switch (e.Status)
{
case FacebookActionStatus.Completed:
var facebookProfile = await Task.Run(() => JsonConvert.DeserializeObject<FacebookProfile>(e.Data));
if (string.IsNullOrWhiteSpace(facebookProfile.Email))
{
Device.BeginInvokeOnMainThread(() =>
{
LoginMsgLbl = "Your social account does not contain an email, an email is required to continue";
});
}
else if (string.IsNullOrWhiteSpace(facebookProfile.Id))
{
Device.BeginInvokeOnMainThread(() =>
{
LoginMsgLbl = "Facebook failed to provide authorization ID please try again.";
});
}
else
{
var socialLoginData = new NetworkAuthData
{
Email = facebookProfile.Email,
FullName = $"{facebookProfile.FirstName} {facebookProfile.LastName}",
FirstName = facebookProfile.FirstName,
LastName = facebookProfile.LastName,
Id = facebookProfile.Id,
Provider = SocialProvider.FaceBook
};
if (facebookProfile is not null)
{
await SocialLogIn(socialLoginData);
}
}
break;
case FacebookActionStatus.Canceled:
break;
case FacebookActionStatus.Error:
await _userDialog.AlertAsync("Error", "Facebook Auth", "Ok");
break;
case FacebookActionStatus.Unauthorized:
await _userDialog.AlertAsync("Unauthorized", "Facebook Auth", "Ok");
break;
}
SpinnerIsRunning = false;
_facebookService.Logout();
_facebookService.OnUserData -= userDataDelegate;
}
_facebookService.OnUserData += userDataDelegate;
string[] fbRequestFields = { "email", "first_name", "last_name" };
string[] fbPermisions = { "email" };
await _facebookService.RequestUserDataAsync(fbRequestFields, fbPermisions);
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
SpinnerIsRunning = false;
}`
@sereoja it seems you do not use your Nuget packages, so what library you use? I don't need to get facebook user data, i need to log in without Facebook app installed :)
@sereoja it seems you do not use your Nuget packages, so what library you use? I don't need to get facebook user data, i need to log in without Facebook app installed :)
you are right, I use this plugin in another plugin, if you want you can look at it, hope it helps:
https://github.com/CrossGeeks/FacebookClientPlugin/blob/master/src/Plugin.FacebookClient/FacebookClientManager.android.cs
@sereoja Thank you now it's working ;)
Any news on this? Would be nice to have an official package working.