FacebookComponents icon indicating copy to clipboard operation
FacebookComponents copied to clipboard

Android 12 Update and SDK update

Open mos379 opened this issue 3 years ago • 31 comments
trafficstars

Since it was quite some time since the latest update..

This solves as well issues #210 #236

mos379 avatar Apr 27 '22 19:04 mos379

CLA assistant check
All CLA requirements met.

net-foundation-cla[bot] avatar Apr 27 '22 19:04 net-foundation-cla[bot]

@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.

mos379 avatar Apr 29 '22 16:04 mos379

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?

mos379 avatar May 02 '22 20:05 mos379

@SotoiGhost looks like You are the only one maintaining this repo. Any chance to have a look at my code and questions?

mos379 avatar May 08 '22 17:05 mos379

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.

sereoja avatar May 18 '22 02:05 sereoja

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 avatar May 18 '22 02:05 sereoja

@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...

mos379 avatar May 18 '22 07:05 mos379

@SotoiGhost could you post the Pipeline logs here so I can figure out why they are failing?

mos379 avatar May 18 '22 08:05 mos379

@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 avatar May 18 '22 17:05 sereoja

@sereoja I get the same errors too. @mos379 any advices on how to build this library locally, while this pull request is open?

skir avatar May 19 '22 14:05 skir

@skir @sereoja did you try to build my main or the main of this project?

mos379 avatar May 19 '22 14:05 mos379

@mos379 I tried to build your main.

skir avatar May 19 '22 14:05 skir

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.

sereoja avatar May 19 '22 20:05 sereoja

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]

jfversluis avatar May 30 '22 11:05 jfversluis

mos379:main

MrAugMyo avatar Jul 15 '22 17:07 MrAugMyo

gh pr checkout 237

MrAugMyo avatar Jul 18 '22 15:07 MrAugMyo

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

Transatranticism avatar Aug 09 '22 02:08 Transatranticism

Is anyone here ? Will this fix be merged one day ? apps have been crashing in prod

DamienDoumer avatar Dec 08 '22 09:12 DamienDoumer

@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.

DamienDoumer avatar Dec 08 '22 11:12 DamienDoumer

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

profilen avatar Dec 08 '22 13:12 profilen

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.

mos379 avatar Dec 08 '22 15:12 mos379

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

profilen avatar Dec 08 '22 16:12 profilen

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

mmilkovski avatar Dec 10 '22 12:12 mmilkovski

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"/>

patkozlowski avatar Mar 03 '23 15:03 patkozlowski

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?

ivanoikon avatar Apr 13 '23 10:04 ivanoikon

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 avatar Apr 13 '23 16:04 sereoja

@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 :)

ivanoikon avatar Apr 14 '23 07:04 ivanoikon

@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 avatar Apr 14 '23 16:04 sereoja

@sereoja Thank you now it's working ;)

ivanoikon avatar Apr 17 '23 10:04 ivanoikon

Any news on this? Would be nice to have an official package working.

alexshikov avatar Oct 03 '23 12:10 alexshikov