[英]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.