提问者:小点点

在没有Google Play服务的情况下使用Google Firebase远程配置?


在设备上没有安装Google Play服务(aosp)的情况下,是否可以使用Firebase Remote Config?

我确实在我的android项目中遵循了这个设置:(通过https://firebase.google.com/docs/android/setup):

  1. 将类路径'com.google.gms:google-services:4.3.3'添加到主分级文件
  2. 将实现“com.google.firebase:firebase-config:19.1.3”和“应用插件:”com.google.gms.google-services“添加到应用程序分级文件

它确实进行了编译,但当我最初启动应用程序fetchAndActivate时并不成功,因为任务在调用fetch()后会产生结果:

MISSING_INSTANCEID_SERVICE(无法获取Firebase实例ID令牌以进行fetch)

  firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
        FirebaseRemoteConfigSettings.Builder configBuilder = new FirebaseRemoteConfigSettings.Builder();
        configBuilder.setMinimumFetchIntervalInSeconds(3600);


        firebaseRemoteConfig.setConfigSettingsAsync(configBuilder.build());
        HashMap<String, Object> defaults = new HashMap<>();
        defaults.put("variant", "basic");
        startActivity(new Intent(getApplicationContext(), CarLauncherBasic.class));

        firebaseRemoteConfig.setDefaultsAsync(defaults);
        firebaseRemoteConfig.fetchAndActivate()
                .addOnCompleteListener(this, new OnCompleteListener<Boolean>() {
                    @Override
                    public void onComplete(@NonNull Task<Boolean> task) {
                        if (task.isSuccessful()) {
                            boolean updated = task.getResult();
                            Toast.makeText(MainActivity.this, "Fetch and activate succeeded",
                                    Toast.LENGTH_SHORT).show();

                        } else {
                            Toast.makeText(MainActivity.this, "Fetch failed",
                                    Toast.LENGTH_SHORT).show();
                        }
                        String variant = firebaseRemoteConfig.getString("variant");

//
                    }
                });

    }

共0个答案