gpt4 book ai didi

android - Firebase - 带有 userProperty 的 RemoteConfig 返回默认值

转载 作者:太空狗 更新时间:2023-10-29 13:06:47 24 4
gpt4 key购买 nike

首先,我为我的英语道歉 :-) 我正在做一个大项目,我在我的 Android 应用程序中使用 Firebase 时遇到了问题。我的 RemoteConfig 具有使用 Analytics 用户属性的条件。当我在应用程序中设置用户属性、获取数据并在成功完成后激活获取的数据时,我仍然从 RemoteConfig 获取参数的默认值,即使 RemoteConfig 条件为真。代码是用 Kotlin 编写的。

这是我的代码示例(此代码在类的 onCreate() 方法中,它扩展了 Appliaction 类:

FirebaseAnalytics.getInstance(this).setUserProperty("testprop", "a");
FirebaseRemoteConfig.getInstance().fetch(0).addOnCompleteListener {
if (it.isSuccessful) {
FirebaseRemoteConfig.getInstance().activateFetched();
val a = FirebaseRemoteConfig.getInstance().getString("test_param");
Log.i("TOAPP", "Test param is $a");
} else {
Log.i("TOAPP", "Error: ${it.exception?.localizedMessage}");
it.exception?.printStackTrace();
}
}
}

Firebase 中的远程配置:
参数 = 测试参数
- 我的用户 = 开发
- 默认值:= 生产

条件:
MyUser - 如果 User 属性 testprop 与 a 完全匹配则适用

当我运行它时,我在控制台中得到了这个:
I/TOAPP: 测试参数是生产

我在 gradle.build 文件中有这些库:

// Play services
implementation "com.google.android.gms:play-services-location:11.4.2"
implementation "com.google.android.gms:play-services-maps:11.4.2"
implementation "com.google.android.gms:play-services-base:11.4.2"
implementation "com.google.android.gms:play-services-identity:11.4.2"
implementation "com.google.android.gms:play-services-places:11.4.2"

// Firebase
implementation "com.google.firebase:firebase-core:11.4.2"
implementation "com.google.firebase:firebase-config:11.4.2"
implementation "com.google.firebase:firebase-messaging:11.4.2"

感谢您的回答。

最佳答案

问题解决了!

在 Firebase 中,我有两个 Andorid 应用程序(旧应用程序版本和新应用程序版本)。旧应用程序运行正常,但新应用程序出现问题。当我在 Firebase Analytics 中打开旧应用程序然后打开用户属性时,我在远程配置条件中使用了一些参数。当我在 Firebase Analytics 中将应用程序切换到新版本时,用户属性为空。我在 Firebase Analytics 中将旧应用版本的相同属性添加到新应用版本,新应用正常运行。

关于android - Firebase - 带有 userProperty 的 RemoteConfig 返回默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46918950/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com