简体   繁体   English

Flutter 中 Firebase 的应用程序检查不起作用

[英]App Check from Firebase in Flutter doesn't work

I'm trying to use App Check from Firebase with Flutter (on Android only for now), but the documentation is just terrible and I don't understand the errors I get when I try to access a Firebase service with an App Check token. I'm trying to use App Check from Firebase with Flutter (on Android only for now), but the documentation is just terrible and I don't understand the errors I get when I try to access a Firebase service with an App Check token.

I run my app on my personal Android device through the terminal using the following command: flutter run --no-sound-null-safety .我使用以下命令通过终端在我的个人 Android 设备上运行我的应用程序: flutter run --no-sound-null-safety

I want to access data on Firebase Storage with that app.我想使用该应用程序访问 Firebase 存储上的数据。 I have enforced App Check on that feature, I have also enabled SafetyNet for my app and I have created a debug token entitled "tests" that I don't even know how to use.我已经对该功能实施了 App Check,我还为我的应用启用了 SafetyNet,并且我创建了一个名为“测试”的调试令牌,我什至不知道如何使用它。

Here is the error I get:这是我得到的错误:

我的错误

Here is my main() function:这是我的main() function:

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_app_check/firebase_app_check.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  await FirebaseAppCheck.instance.activate();

  // ... not related code

  runApp(MyWidget())
}

Here is my build.gradle in /android/app/ :这是我在/android/app/中的build.gradle

// ...

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-appcheck-safetynet:16.0.0-beta03'
}

Here is my MainActivity.kt in /android/app/src/main/kotlin/com/example/my_app/ :这是我在/android/app/src/main/kotlin/com/example/my_app/中的MainActivity.kt

// the package

import io.flutter.embedding.android.FlutterActivity
import android.os.Bundle
import com.google.firebase.FirebaseApp
import com.google.firebase.appcheck.FirebaseAppCheck
import com.google.firebase.appcheck.safetynet.SafetyNetAppCheckProviderFactory

class MainActivity: FlutterActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        FirebaseApp.initializeApp(/*context=*/ this);
        val firebaseAppCheck = FirebaseAppCheck.getInstance()
        firebaseAppCheck.installAppCheckProviderFactory(SafetyNetAppCheckProviderFactory.getInstance())
        super.onCreate(savedInstanceState)
    }
}

Please help me guys, nothing works now.请帮助我,现在没有任何工作。

FirebaseApp.initializeApp(/ context= / this); FirebaseApp.initializeApp(/ context= /this); You have there semicolon, it's kotlin code, in kotlin we don't use semicolon.你有分号,它是 kotlin 代码,在 kotlin 我们不使用分号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter Firebase Google Play 无法进行身份验证 - Flutter Firebase Auth doesn't work from Google Play Flutter Firebase GoogleSignIn 在发行版中不起作用 - Flutter Firebase GoogleSignIn doesn't work in release 使用firebase在app中进行路由并不正确 - Routing in app with firebase doesn`t work correct Firebase 在flutter web 上不起作用,但在android 模拟器上运行良好 - Firebase doesn't work on flutter web but fine on android emulator "Flutter Firebase Google Auth 在生产中不起作用" - Flutter Firebase Google Auth doesn't work in production Flutter - Firebase onLaunch 中的云消息导航不起作用 - Flutter - Firebase Cloud Messaging Navigation in onLaunch doesn't work .once() 在使用 Flutter 和 Firebase 时似乎不起作用/无法识别 - .once() doesn't seem to work / recognized while working with Flutter & Firebase Firebase 因无效安全(DART/FLUTTER)而不起作用 - Firebase doesn't work cause of null-safety (DART/FLUTTER) 试图处理 firebase 存储异常不起作用(颤振) - trying to handle firebase storage exception doesn't work (flutter) 我正在尝试使用 Firebase 在 Flutter 中使用 Google 注销,但它不起作用 - I'm trying to signOut with google in Flutter with Firebase and it doesn't work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM