skip to Main Content

I’m using this guide to implement the new app check Play Integrity: https://firebase.google.com/docs/app-check/android/play-integrity-provider?authuser=0&hl=de#java_1

at step 3 it is mentioned to add this initialization code:

FirebaseApp.initializeApp(/*context=*/ this);
FirebaseAppCheck firebaseAppCheck = FirebaseAppCheck.getInstance();
firebaseAppCheck.installAppCheckProviderFactory(
        PlayIntegrityAppCheckProviderFactory.getInstance());

But where??

I tried it in main.dart, MainActivity.java and Application.jave with no success. Maybe I need some more packages? it would help me a lot if i know where to try

2

Answers


  1. Chosen as BEST ANSWER

    the code must be inserted in the MainActivity.java and you need additional these package (not mentioned in the google guide)

    In MainActivity.java:

    import com.google.firebase.FirebaseApp;
    import com.google.firebase.appcheck.FirebaseAppCheck;
    import com.google.firebase.appcheck.playintegrity.PlayIntegrityAppCheckProviderFactory;
    

    In pubspec.yaml:

    firebase_app_check: ^0.1.1+8
    

    this helped me: Error while handling Appcheck with flutter


  2. If you use firebase in flutter. Then I think it should help you

    import 'package:firebase_core/firebase_core.dart';
    
    void main(List<String> args) {
          // required line
          WidgetsFlutterBinding.ensureInitialized();
          // init firebase
          FirebaseApp.initializeApp();
          FirebaseAppCheck firebaseAppCheck = FirebaseAppCheck.getInstance();
          firebaseAppCheck.installAppCheckProviderFactory(
                 PlayIntegrityAppCheckProviderFactory.getInstance());
          // run app
          runApp(const MyApp()));
     }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search