问题
Facebook login is working with release APK before publishing App, but not after publishing same APK in Play Store.
I am trying to implement Facebook Login into my app from past 2 days. I have followed all the steps and added both key-hash (for debug and release) into my app at facebook developer account.
Its working fine with both type of build variant before publishing app in Play Store, but after downloading same release variant (which I am testing before publishing app) from Play Store, Facbook Login is not working.
One more thing is that Facebook Login is not working only if Facebook app is installed in device. If App is not installed, its working fine with web view.
I have used below code to get debug and release key-hash by changing build variants in android studio:
try {
PackageInfo info = getPackageManager().getPackageInfo("com.my.package.name", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (PackageManager.NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
My app is available for public in Facebook developer account
I am not getting what I am doing wrong or what I am missing. Please help !
Your help will be highly appreciated. Thank you.
回答1:
When the app is published, Google make a new fingerprint for your apk. Add the new fingerprint. It might work.
回答2:
Solved
I have converted SHA-1 certificate fingerprints provided by play store to 28 characters key-hash for facebook login using below method:
// Play Store App Signing SHA-1 Key (Example):- 9A:B0:98:16:76:23:B5:9A:55:83:00:FF:76:0E:B6:B9:C6:FE:A3:C7
byte[] sha1KeyHash = {(byte) 0x9A, (byte) 0xB0, (byte) 0x98, (byte) 0x16, (byte) 0x76, (byte) 0x23, (byte) 0xB5, (byte) 0x9A, (byte) 0x55, (byte) 0x83, (byte) 0x00, (byte) 0xFF, (byte) 0x76, (byte) 0x0E, (byte) 0xB6, (byte) 0xB9, (byte) 0xC6, (byte) 0xFE, (byte) 0xA3, (byte) 0xC7};
System.out.println("keyHashForFacebookLogin: " + Base64.encodeToString(sha1KeyHash, Base64.NO_WRAP));
I have used this key-hash in my facebook developer account..
And its working perfectly..
来源:https://stackoverflow.com/questions/46430280/facebook-login-is-working-with-release-apk-before-publishing-app-but-not-after