How can I install Firebase AppCheck in my Android React Native project?
Asked Answered
E

2

6

I have secured my project with Appcheck in Firebase, I have two apps in my firebase project in which one of them is a web app (https://host-bloodhelper.web.app/) and the another is an Android app (React Native app). I am using the react-native-firebase library which I have installed in my project using Yarn. I am only using firebase real-time database API which is working fine when I have appCheck Unenforced (turned off). I can't find any docs on how to install appCheck in React native on Android, not even on the official website.

My index.js file:

/**
 * @format
 */

import { AppRegistry } from 'react-native';
import App from './App';
import { name as appName } from './app.json';
import firebase from '@react-native-firebase/app'


AppRegistry.registerComponent(appName, () => App); 

App.js:

// App.js is in functional component because of React navigation router.
// Every class component is wrapped in a functional component.

import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import Login from './screens/login'
import Register from './screens/register'
import Registerb from './screens/registerb'
import Home from './screens/home'
import Profile from './screens/profile'
import Userprofile from './screens/userprofile'
import Deleteacc from './screens/deleteacc'
import Addbloodtype from './screens/addbloodtype'
import Privacy from './screens/privacy'


const Stack = createStackNavigator();

export default function App() {
    return(
      <NavigationContainer>
      <Stack.Navigator
        screenOptions={{
          headerShown: false
        }}
      >
        <Stack.Screen name="Register" component={Register} />
        <Stack.Screen name="Registerb" component={Registerb} />
        <Stack.Screen name="Login" component={Login} />
        <Stack.Screen name="Home" component={Home} />
        <Stack.Screen name="Profile" component={Profile} />
        <Stack.Screen name="Userprofile" component={Userprofile} />
        <Stack.Screen name="Deleteacc" component={Deleteacc} />
        <Stack.Screen name="Addbloodtype" component={Addbloodtype} />
      </Stack.Navigator>
    </NavigationContainer>
    )
}

Package.json:

{
  "name": "BloodHelper",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-firebase/analytics": "^12.6.0",
    "@react-native-firebase/app": "^12.6.0",
    "@react-native-firebase/database": "^12.6.0",
    "@react-native-picker/picker": "^1.9.10",
    "@react-navigation/native": "^5.9.0",
    "@react-navigation/stack": "^5.13.0",
    "firebase": "^8.2.3",
    "react": "16.13.1",
    "react-native": "0.63.4",
    "react-native-elements": "^3.3.2",
    "react-native-gesture-handler": "^1.9.0",
    "react-native-loading-spinner-overlay": "^2.0.0",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^2.16.1",
    "react-native-startapp-ads-module": "^0.0.10",
    "react-native-vector-icons": "^8.1.0",
    "react-native-webview": "^11.6.5",
    "react-navigation": "^4.4.3",
    "react-navigation-stack": "react-navigation/stack",
    "rm": "^0.1.8"
  },
  "devDependencies": {
    "@babel/core": "^7.12.10",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "^7.18.0",
    "jest": "^26.6.3",
    "jetifier": "^2.0.0",
    "metro-react-native-babel-preset": "^0.64.0",
    "react-test-renderer": "16.13.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

Firebase AppCheck: Firebase AppCheck Screenshot
Recaptcha is working fine on my website but SafetyNet is not working in React Native on Android.
Can anyone explain to me how I can install appCheck in React Native on Android. Any help is appreciated.

Exposition answered 18/8, 2021 at 11:10 Comment(0)
L
0

Not sure if this will help at all but I was having the same problem with my react based web app and eventually came across this page that shows how to install and initialize app check in JS. I've never used React-Native but it should be easy enough to convert the JS examples on this page https://firebase.google.com/docs/app-check/web/recaptcha-provider

Logistician answered 20/4, 2022 at 21:13 Comment(0)
G
0

react-native-firebase has app-check support - still like you said documentation currently (11/2022) is very vague.
Will update.

Gerhard answered 23/11, 2022 at 10:59 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.