Installation & Setup
Installation
npm install react-native-credentials-manager
# or if you prefer yarn
yarn add react-native-credentials-manager
Android Setup
To implement the Credential Manager API in your Android application, follow these steps:
1. Digital Asset Links Setup
To enable passkey support, you need to associate your Android app with your website by creating and hosting a Digital Asset Links JSON file.
Create a file named assetlinks.json
with the following content:
[
{
"relation": [
"delegate_permission/common.handle_all_urls",
"delegate_permission/common.get_login_creds"
],
"target": {
"namespace": "android_app",
"package_name": "your.package.name",
"sha256_cert_fingerprints": [
"YOUR_APP_SIGNING_CERTIFICATE_SHA256_FINGERPRINT"
]
}
}
]
Host this file at:
https://your-domain.com/.well-known/assetlinks.json
Important Requirements
- The MIME type must be
application/json
- If you have a
robots.txt
, ensure it allows access to/.well-known/assetlinks.json
:User-agent: *
Allow: /.well-known/ - The domain must be fully-qualified
- Don't include trailing slashes or paths in the domain
- Subdomains are not automatically included in the association
2. ProGuard Configuration
If you're using ProGuard in your Android application, add these rules to your android/app/proguard-rules.pro
:
-if class androidx.credentials.CredentialManager
-keep class androidx.credentials.playservices.** {
*;
}
3. Google Sign-In Setup (Optional)
If you plan to use Google Sign-In:
- Configure your project in the Google Cloud Console
- Create OAuth 2.0 credentials
- Add your application's SHA-1 signing certificate fingerprint
- Note down your Web Client ID for use in the application
iOS Setup
note
iOS support using Authentication Services is coming soon.
Troubleshooting
Common Issues
-
Digital Asset Links Not Working
- Ensure your
assetlinks.json
file is accessible via HTTPS - Verify the SHA-256 fingerprint matches your app's signing certificate
- Check that the package name matches your Android app exactly
- Ensure your
-
ProGuard Issues
- Make sure the ProGuard rules are properly added
- Clean and rebuild your project after adding the rules
-
Build Errors
- Ensure you're using a compatible React Native version
- Clean the project and rebuild:
cd android
./gradlew clean
For additional help, please check the GitHub issues or create a new issue if you encounter any problems.