|
5 | 5 | package io.flutter.plugins.firebase.appcheck;
|
6 | 6 |
|
7 | 7 | import androidx.annotation.Keep;
|
| 8 | + |
| 9 | +import com.google.firebase.appcheck.debug.InternalDebugSecretProvider; |
8 | 10 | import com.google.firebase.components.Component;
|
9 | 11 | import com.google.firebase.components.ComponentRegistrar;
|
10 | 12 | import com.google.firebase.platforminfo.LibraryVersionComponent;
|
| 13 | + |
| 14 | +import java.util.Arrays; |
11 | 15 | import java.util.Collections;
|
12 | 16 | import java.util.List;
|
13 | 17 |
|
14 | 18 | @Keep
|
15 | 19 | public class FlutterFirebaseAppRegistrar implements ComponentRegistrar {
|
| 20 | + private static final String DEBUG_SECRET_NAME = "fire-app-check-debug-secret"; |
| 21 | + |
16 | 22 | @Override
|
17 | 23 | public List<Component<?>> getComponents() {
|
18 |
| - return Collections.<Component<?>>singletonList( |
19 |
| - LibraryVersionComponent.create(BuildConfig.LIBRARY_NAME, BuildConfig.LIBRARY_VERSION)); |
| 24 | + Component<?> library = LibraryVersionComponent.create(BuildConfig.LIBRARY_NAME, |
| 25 | + BuildConfig.LIBRARY_VERSION); |
| 26 | + |
| 27 | + if (BuildConfig.FIREBASE_APP_CHECK_DEBUG_TOKEN == null) |
| 28 | + return Collections.<Component<?>>singletonList( |
| 29 | + LibraryVersionComponent.create(BuildConfig.LIBRARY_NAME, |
| 30 | + BuildConfig.LIBRARY_VERSION)); |
| 31 | + |
| 32 | + Component<InternalDebugSecretProvider> debugSecretProvider = Component.builder(InternalDebugSecretProvider.class) |
| 33 | + .name(DEBUG_SECRET_NAME) |
| 34 | + .factory(container -> () -> BuildConfig.FIREBASE_APP_CHECK_DEBUG_TOKEN).build(); |
| 35 | + |
| 36 | + return Arrays.<Component<?>>asList(library, debugSecretProvider); |
20 | 37 | }
|
21 | 38 | }
|
0 commit comments