How to activate App Check in android @react-native-firebase/app-check #5660
-
I went through the documentation of app-check, but i can't able to understand how to activate the app-check in android. Where should we call the activate method in the app.js or in the navigation file. Please can anyone help me in that. |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 13 replies
-
Hi there! Have you looked at how we do it? Examining the "test" aspects of the implementing PR: Or at the test app itself is instructive In short, for android you may activate any time, but it obliterates any other existing providers. It is difficult to set up DebugProviders currently, unfortunately - you may track that here firebase/firebase-ios-sdk#8584 and there's a linked comment from FlutterFire there that indexes right back here with deep links to the strategies we use - I won't repeat them but they might be very useful so I mention |
Beta Was this translation helpful? Give feedback.
-
@mikehardy For example: export const appCheckActivate = () => {
if (isIOS()) {
return
}
return firebase.appCheck().activate('????', true) // What create this first parameter?
} |
Beta Was this translation helpful? Give feedback.
-
Hello there, I too am trying to activate AppCheck in our app. So far, we've followed the first config steps described in firebase documentation (for both iOS and Android), managed to activate appCheck, and then tried to get the token but failed with
The error I'm getting if I try to get the token is: I ran the app in Android emulator, with both the debug and production build and threw the error. Is it because I need the app the be installed from the app store in a real device? Thanks! |
Beta Was this translation helpful? Give feedback.
-
Just to add to this, if you're struggling to get this working on an Android release build make sure you generate a build signed with the same Keystore that you generated your SHA-256 certificate fingerprint with. Otherwise, release build or not, your app won't be able to authenticate with SafetyNet. |
Beta Was this translation helpful? Give feedback.
-
I am trying to implementing a PoC of a debug app working with a configured token based on the changes @mikehardy mentioned In MainApplication.java I have:
In build.gradle I have added: dependencies {
...
implementation 'com.google.firebase:firebase-appcheck-debug:16.0.0-beta02'
+ implementation 'com.google.firebase:firebase-appcheck-debug-testing:16.0.0-beta02'
} And in my React App I do:
I have also added generated debug token in the firebase console. This is however still not working as I keep getting a permission denied error:
Which I can confirm is a AppCheck error since I can see it in the analytics. I am honestly not sure where to go from here so if anyone has a pointer, that would be much appreciated. |
Beta Was this translation helpful? Give feedback.
-
@mikehardy So it turns out there was quite an elegant solution that could be implemented. I've illustrated this in details in a separate branch[1] but here is the summary of the solution:
I believe this could be worth a PR, but before I go ahead, I'd like to get your thoughts on the implementation. Cheers! |
Beta Was this translation helpful? Give feedback.
-
Thanks for all the (timely) help @mikehardy! Here's the PR #6026. Cheers! |
Beta Was this translation helpful? Give feedback.
-
My app check is working fine. But when i try to get the token as suggested by @RyanMan56 it shows undefined without any errors.
change |
Beta Was this translation helpful? Give feedback.
Hi there! Have you looked at how we do it? Examining the "test" aspects of the implementing PR:
99cd4e5
Or at the test app itself is instructive
https://github.com/invertase/react-native-firebase/blob/master/packages/app-check/e2e/appcheck.e2e.js
In short, for android you may activate any time, but it obliterates any other existing providers.
For iOS you must have the Provider you want set up before
[FIRApp configure]
is called (which is a little tough, yesIt is difficult to set up DebugProviders currently, unfortunately - you may track that here firebase/firebase-ios-sdk#8584 and there's a linked comment from FlutterFire there that indexes right back here with deep links to the strategi…