我正在尝试使用以下代码在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.'
我在这里做什么错了?
答案 0 :(得分:0)
根据official docs,看起来仅支持setValue
方法。
尝试
(googleAnalytics.getTracker() as any).setValue((global as any).GAIFields.customDimensionForIndex(key), value);