Key hash doesn't match while facebook login in android

前端 未结 9 1796
谎友^
谎友^ 2020-12-03 07:41

My app uses a simple facebook login. I have entered the keyhash in my app dashboard, key_hash section and I was able to login successfully. Now I have published the app and

9条回答
  •  误落风尘
    2020-12-03 08:26

    Here is the C# version for the benefit of anyone trying to get the Xamarin sample to work.

        public  void showHashKey(Context context) 
        {
            try {
                PackageInfo info = context.PackageManager.GetPackageInfo("com.facebook.samples.hellofacebook", PackageInfoFlags.Signatures);
                foreach (Android.Content.PM.Signature signature in info.Signatures) {
                    MessageDigest md = MessageDigest.GetInstance("SHA");
                    md.Update(signature.ToByteArray());
    
                    var sign = Base64.EncodeToString(md.Digest(), Base64Flags.Default);
                    Log.Info("KeyHash:", sign);
                }
                Log..Info("KeyHash:", "****------------***");
            } catch (PackageManager.NameNotFoundException e) {
                e.PrintStackTrace();
            } catch (NoSuchAlgorithmException e) {
                e.PrintStackTrace();
            }
        }
    

提交回复
热议问题