我在启动时覆盖 Android 应用程序的区域设置,并允许在运行时更改区域。我像这样设置区域设置:
Resources res = context.getResources();
Configuration configuration = res.getConfiguration();
DisplayMetrics metrics = res.getDisplayMetrics();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
configuration.setLocale(locale);
}else{
configuration.locale = locale;
}
Locale.setDefault(locale);
res.updateConfiguration(configuration, metrics);
Run Code Online (Sandbox Code Playgroud)
现在我想将 Firebase-Remote-Config 与区域/国家条件一起使用。例如
test_property -> fr_FR = Bonjour
-> de_DE = Hallo
-> default = Hi
Run Code Online (Sandbox Code Playgroud)
如果我现在将我的设备设置为 de_DE 并且将我的应用程序设置为我将从区域( )fr_FR获取。我想要得到的是该地区的test_propertyde_DEHallotest_propertyfr_FR应用程序设置的
我尝试过了FirebaseApp.initializeApp(...)我在更改应用程序中的区域后
有人知道如何以编程方式设置/覆盖该区域,以便 firebase 将该区域用于区域条件吗?
我不想使用 Firebase Analytics User Properties,因为它们更新得太晚了。
我使用国家/地区条件创建了在日本返回 true 其他 false 的参数。
然后我在我的应用程序上获取了参数,但是在没有 VPN 连接到美国的情况下,该参数没有改变。
我们可以使用 vpn 测试国家/地区条件吗?国家/地区条件如何检查地理信息?
我在我的应用程序中使用了 firebase remote-config。我有两个参数 message1 和 message2,如下图所示。语言条件也可以在图像中看到(阿拉伯语和法语)。
用户可以选择在应用程序开始时选择应用程序语言(单独的活动),这是我用来更改语言的代码:
Locale locale = new Locale("ar");//or "fr" if user selects french
Locale.setDefault(locale);
Configuration configuration = new Configuration();
configuration.locale = locale;
getResources().updateConfiguration(configuration, getResources().getDisplayMetrics());
Run Code Online (Sandbox Code Playgroud)
这是我用来从 firebase 获取数据的代码:
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
mFirebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
long cacheExpiration = 0;
mFirebaseRemoteConfig.fetch(cacheExpiration)
.addOnCompleteListener(MainActivity.this, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(MainActivity.this, "Fetch Succeeded",
Toast.LENGTH_SHORT).show();
// After config data is successfully fetched, it must be activated before newly fetched
// values are returned.
mFirebaseRemoteConfig.activateFetched();
} else { …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行一个实验来改变应用程序第 3 步中元素的行为。为了使数据准确,我计划将激活事件作为完成步骤 2 的事件。现在,当应用程序首次启动时会获取 firebase 远程配置值,因此如果我将第 2 步完成设置为激活事件,应用程序将无法获取更新的远程配置值以用于第 3 步中使用的标志。如果我每次使用标志时都获取并激活标志值,那将在 60 分钟内超过 5 次的限制。解决这个问题的最佳方法是什么?
Firebase A/B 测试是否考虑了由 设置的用户 ID FirebaseAnalytics.setUserId?这是我的用例:
John Doe 打开应用程序FirebaseAnalytics.setUserId 被称为 johnDoeUserIdVariantAJohn Doe 在其他设备(同一 Google 帐户)上打开应用FirebaseAnalytics.setUserId 被称为 johnDoeUserIdVariantA?不userId具有A / B测试什么意义?
我正在将 Firebase 用于我的 iOS 应用。对于使用我的应用程序旧版本的用户,我希望能够强制他们从 App Store 更新他们的应用程序,以便能够继续使用该应用程序。为此,我正在检查应用程序中的远程配置值,如果确实如此,用户将收到一条全屏消息进行更新。在 Firebase 控制台远程配置中,我正在检查应用程序的版本以将远程配置值设置为 true/false。见下图。
问题是我希望能够使用“where version < X”来设置值,或者如果这是不可能的,至少能够选择一个以上的版本(其中版本是 X 或 Y 或 Z)。
这一定是一个常见的用例,但我不知道如何做到这一点。有谁知道怎么做?我可以使用正则表达式,但如何使用?
在调试模式下,我已经将最小间隔设置为 0。目前,我为获取新数据所做的工作是在启动应用程序之前先清除应用程序存储空间。
这是我的代码:
private fun initRemoteConfig() {
remoteConfig = FirebaseRemoteConfig.getInstance()
configSettings = FirebaseRemoteConfigSettings.Builder()
.setMinimumFetchIntervalInSeconds(if (BuildConfig.DEBUG) 0 else 3600)
.build()
remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)
fetch()
}
private fun fetch() {
remoteConfig.fetchAndActivate()
.addOnCompleteListener {
if (it.isSuccessful) {
val updated = it.result
Logger.d(TAG, "Config params updated: $updated. Fetch and activate succeeded") // updated = false
checkVersion()
} else {
Logger.d(TAG, "Fetch failed")
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试通过 Firebase 远程配置放置我的 ADMOB 广告,以便我可以远程更改它,以防我的 admob 帐户以某种方式终止
我遵循了远程实现的教程。但我面临的问题是 AndroidManifest.xml
******************************************************************************
* The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers *
* should follow the instructions here: *
* https://googlemobileadssdk.page.link/admob-android-update-manifest *
* to add a valid App ID inside the AndroidManifest. *
* Google Ad Manager publishers should follow instructions here: *
* https://googlemobileadssdk.page.link/ad-manager-android-update-manifest. *
******************************************************************************
Run Code Online (Sandbox Code Playgroud)
我相信我应该像这样插入我的 App ID
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
Run Code Online (Sandbox Code Playgroud)
但我不想使用我之前提到的静态 AdMob App ID 那么我如何以编程方式插入值
谢谢
我最近升级了 Flutter 项目中的所有 firebase 库。之后,我收到消息:
/flutter (27126): [ERROR:flutter/shell/platform/android/platform_view_android_jni_impl.cc(43)] java.lang.NoSuchMethodError: Lcom/google/firebase/remoteconfig/FirebaseRemoteConfigSettings 类中没有虚拟方法 isDeveloperModeEnabled()Z;或其超类('com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings' 的声明出现在 /data/app/package_name-1UBO7FEPHLsC2_eb7itJLA==/base.apk!classes3.dex 中)
之后,我的应用程序因错误而崩溃:
[致命:flutter/shell/platform/android/platform_view_android_jni_impl.cc(942)] 检查失败:CheckException(env)。
目前我正在使用:
firebase_remote_config: ^0.4.0+2
firebase_core:0.5.0+1
我在 android/build.gradle 中的依赖项:
dependencies {
classpath 'com.android.tools.build:gradle:3.6.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.4'
classpath 'io.fabric.tools:gradle:1.28.1'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
}
Run Code Online (Sandbox Code Playgroud)
android/app/build.gradle
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.firebase:firebase-config:20.0.0'
implementation 'com.facebook.android:facebook-login:7.1.0'
implementation 'com.google.firebase:firebase-messaging:21.0.0'
implementation 'com.google.android.gms:play-services-basement:17.5.0'
configurations.all {
resolutionStrategy.force 'com.google.android.gms:play-services-base:17.1.0'
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 firebase 部署 Web 应用程序,但每次运行 deploy 时,我都会收到此错误
Error: Parse Error in remoteconfig.template.json:
No data, empty input at 1:1
^
File: "remoteconfig.template.json"
Run Code Online (Sandbox Code Playgroud)