通过NativeScript在GAITracker上调用方法时出错

时间:2019-04-19 14:53:25

标签: nativescript

我正在尝试使用以下代码在iOS中调用本机GoogleAnalytics跟踪器:

(googleAnalytics.getTracker() as any).setValueForKey(value, (global as any).GAIFields.customDimensionForIndex(key));

({value是一个字符串,GAIFields.customDimensionForIndex(key)的输出也是一个字符串)

但是我收到此错误:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<GAITrackerImpl 0x2811e94a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key &cd1.'

我在这里做什么错了?

1 个答案:

答案 0 :(得分:0)

根据official docs,看起来仅支持setValue方法。

尝试

(googleAnalytics.getTracker() as any).setValue((global as any).GAIFields.customDimensionForIndex(key), value);