samedi 18 avril 2015

Understanding app hashes on facebook app

When I try and click the button "Log in with Facebook", the loading animation appears and nothing happens. If I remove all hashes it opens the login screen but fails saying there are no hashes present. Am I supposed to be using developer or release hashes? What exactly am I missing here? I'm generating the hashes with this code:



try {
PackageInfo info = getPackageManager().getPackageInfo(
"PACKAGE",
PackageManager.GET_SIGNATURES);
for (android.content.pm.Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.wtf("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (PackageManager.NameNotFoundException e) {

} catch (NoSuchAlgorithmException e) {

}


EDIT:


I have the following code for the facebook login in an android Fragment:



loginButton = (LoginButton) fragment.findViewById(R.id.login_button);
loginButton.setReadPermissions("user_friends");
// If using in a fragment
loginButton.setFragment(this);
// Other app specific specialization

// Callback registration
loginButton.registerCallback(C.callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {

Log.wtf("onSuccess",loginResult.toString());

}

@Override
public void onCancel() {

Log.wtf("onCancel","");
}

@Override
public void onError(FacebookException exception) {
Log.wtf("onError",exception.toString());
}
});

Aucun commentaire:

Enregistrer un commentaire