2

I am writing an application using Ionic and Phonegap and am running into a problem trying to integrate the Facebook plugin that you can get at https://github.com/Wizcorp/phonegap-facebook-plugin

I understand that I need to add a hash key to my Facebook developer account (release and debug mode) and have done this following the processes outlined at http://developer.android.com/tools/publishing/app-signing.html

I build and push my app to android using Cordova build android or Phonegap build android and the app is happily built and pushed to my phone.

The app is running along and the plugin API is working because it opens up the facebook app to authenticate but I get the error message. Facebook Invalid key hash. The key hash xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx does not match any stored key hashes. Configure your app key hashes at etc..

I have tried manually dropping the debug-unaligned,Still not working

Can anyone help me out or point me in the right direction?

1 Answers1

2

In Android you can generate HASH KEY by below code:

public void generateFacebookHashKey()
    {

        try
        {
            PackageInfo info = getPackageManager().getPackageInfo("Your package name", PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures)
            {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                Log.d("TEMPTAGHASH KEY:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
            }
        }
        catch (NameNotFoundException e)
        {

        }
        catch (NoSuchAlgorithmException e)
        {

        }

    }

Check this Hashkey and key which you used in facebook developer account are same or not ?

If not then you are using wrong key.

Hope it will help you.

KishuDroid
  • 5,411
  • 4
  • 30
  • 47
  • I have done this earlier but, Once I got the same key hash with both the ways i.e. Using keytool command and programmatically respectively. – Jaimin Modi Oct 23 '15 at 12:19
  • 1
    But check it with your developer account and if you run your code from different device your hash key gets changed. – KishuDroid Oct 23 '15 at 12:21