Its been year since App Check was introduce, back then we tried to implement in one of our project the enforced services like Firestore and Storage but both service has stopped working due to denied permission.
PERMISSION_DENIED: Missing or insufficient permissions.
Year after, we once tried it again on a new project that is also available at Play Store. According to this documentation appcheck-playintegrity
should be use when the app is available at Play Store and must be linked. Linking the project is easy with just a few clicks and it also provides/fill up the SHA 256 for debug, release, and the one that is handle by Play Store. Now we cannot sure yet if that will work fine so we enforced Storage and Firstore services, in order to run the app in emulation environment according to the same documentation you should add appcheck-debug
dependency and use its provider. This is what we came up.
Inside Application class
FirebaseApp.initializeApp(this)
FirebaseAppCheck.getInstance().installAppCheckProviderFactory(
if (BuildConfig.DEBUG)
DebugAppCheckProviderFactory.getInstance()
else
PlayIntegrityAppCheckProviderFactory.getInstance()
)
But the Firestore still not working with same permission issue. We also already added a local debug token and it didn't work. We tried to make the Firestore security to accept all writes, it didn't work either.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
The only thing that works is whenever we unenforced the Firestore.
Sample code:
Firebase.firestore.collection("Sample").document().set(
CommonNotification(channel = "Sample", title = "Sample", description = "Sample")
).addOnFailureListener {
it.printStackTrace()
}
I am using an emulator but according to the documentation it should work as long as you use DebugAppCheckProviderFactory.getInstance()