在设备上没有安装Google Play服务(aosp)的情况下,是否可以使用Firebase Remote Config?
我确实在我的android项目中遵循了这个设置:(通过https://firebase.google.com/docs/android/setup):
它确实进行了编译,但当我最初启动应用程序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");
//
}
});
}