Firebase Analytics自定义值列表

Nel*_*dra 5 android firebase-analytics

我正在尝试使用bundle方法,putStringArrayList()但我总是在firebase控制台中收到错误.

Bundle bundle = new Bundle();

ArrayList<String> types = new ArrayList<String>();
types.add("test1");
types.add("test2");
bundle.putStringArrayList("Types", types);

mFirebaseAnalytics.logEvent("MainActivity", bundle);
Run Code Online (Sandbox Code Playgroud)

在Firebase控制台中,我收到此错误:

error_value Types
firebase_error 4
Run Code Online (Sandbox Code Playgroud)

以及分析错误代码的链接(事件参数值太长).

我应该如何为特定密钥发送多个值?

Ven*_*ana 8

根据logEvent的API文档,params包描述说

支持字符串,参数类型.

您收到此错误,因为您使用的param类型不支持String数组列表的映射.看一下firebase google组中的这个讨论.

你可以做这样的事情,基本上是相同的.

bundle.putString("Types", types.toString());
Run Code Online (Sandbox Code Playgroud)

  • 请注意,字符串参数有 [100 个字符的限制](https://firebase.google.com/docs/reference/unity/class/firebase/analytics/parameter.html)。对于长数组,.toString() 可能会失败。 (2认同)