I am trying to implement Sms Retriever for fetching an otp from user mobile without having any SMS permission.
Initially, I have generated a hash key with the keystore(.jks) by using keytool as described here
when I signed the apk with this keystore and received the SMS with this hashkey, it is working properly.
But After uploaded the app to google play store, the SMS receiver is not working .we have enabled google app signing to sign the app. I found that Google will remove the uploaded signature, a key for the apps using google app signing as described here. So, I was trying to add the google app signing certificate to the uploaded keystore with the alias name for creating new hashkey.But I am unable to add the app signing certificate to the keystore with alias name.
Any suggestions to generate the hashkey with app signing certificate for sms retriever?
Step 1:- Go to your Google Play Console and Select your App. Step 2:- Go to Release Section => Setup => App integrity and Click on Request key upgrade.
In the Google Play Console App Signing page, select “Export and upload a key from Android Studio” and upload the key Android Studio generated. If you're using a Java keystore to sign your apps, select the “Export and upload a key from a Java keystore” in the Google Play Console App Signing page.
Open one of your Android projects (choose one at random). Go to Build -> Generate Signed APK and press Create new.
When Google's App Signing enable 11 char hash will be generated without alias
i.e SMS Retrieve API
The following command computes the hash string from your app's production keystore:
keytool -exportcert -alias MyAndroidKey -keystore MyProductionKeys.keystore | xxd -p | tr -d "[:space:]" | echo -n com.example.myapp `cat` | sha256sum | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11
in the above command hash is generating based on MyAndroidKey alias (-alias MyAndroidKey
).
Try generating hash without alias for Google APK Sign Enabled
i.e
keytool -exportcert -keystore MyProductionKeys.keystore | xxd -p | tr -d "[:space:]" | echo -n com.example.myapp `cat` | sha256sum | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11
Since, Play App is also signing app so we have to generate a .jks file and we'll have to use this .jks file produced by the deployement_cert.der (Downloaded from Google play console), for getting the 11 char hash code. follow the steps:
The .jks file is required to generate the 11 char hash code,
To create .jks file
Download .der file from google play console.
https://i.stack.imgur.com/KUK6i.png
keytool -importcert -alias YOUR_ALIAS -file deployment_cert.der -keystore app_keystore.jks -storepass YOUR_KEYSTORE_PWD
It will generate a app_keystore.jks file.
3. Then use the generated keystore for generating the 11 char hashcode.
keytool -exportcert -alias YOUR_ALIAS -keystore app_keystore.jks | xxd -p | tr -d "[:space:]" | echo -n COM.EXAMPLE.MYAPP
cat
| sha256sum | tr -d " [:space:]-" | xxd -r -p | base64 | cut -c1-11
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With