[英]Google Tag Manager with Firebase crash iOS
I'm using Google Tag Manager with Firebase in my app.我在我的应用程序中使用带有 Firebase 的 Google 跟踪代码管理器。
Here is my code that log screens and events:这是我记录屏幕和事件的代码:
import FirebaseAnalytics
import Foundation
public class AnalyticManager {
public static func logScreen(_ name: String, className: String?) {
Analytics.setScreenName(name, screenClass: className)
Analytics.logEvent("open_screen", parameters: ["screenName": name])
}
}
When I launch my app, I'm getting this crash:当我启动我的应用程序时,我遇到了这个崩溃:
2020-04-29 17:05:52.189148+0000 MyApp[15962:354528] -[__NSDictionaryM length]: unrecognized selector sent to instance 0x60000033a500
2020-04-29 17:05:52.191676+0000 MyApp[15962:354528] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM length]: unrecognized selector sent to instance 0x60000033a500'
*** First throw call stack:
(
0 CoreFoundation 0x000000011719cf0e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00000001170089b2 objc_exception_throw + 48
2 CoreFoundation 0x00000001171bdc34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00000001171a190c ___forwarding___ + 1436
4 CoreFoundation 0x00000001171a3bf8 _CF_forwarding_prep_0 + 120
5 MyApp 0x000000010f9f597f -[GAIBatchingDispatcher queueDispatch:] + 385
6 MyApp 0x000000010f9f57e4 -[GAIBatchingDispatcher queueModel:] + 125
7 Foundation 0x0000000114543f42 __NSThreadPerformPerform + 209
8 CoreFoundation 0x0000000117100eb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
9 CoreFoundation 0x0000000117100ddc __CFRunLoopDoSource0 + 76
10 CoreFoundation 0x00000001171005b4 __CFRunLoopDoSources0 + 180
11 CoreFoundation 0x00000001170fb1ae __CFRunLoopRun + 974
12 CoreFoundation 0x00000001170faac4 CFRunLoopRunSpecific + 404
13 Foundation 0x000000011452dd71 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 211
14 Foundation 0x000000011452df85 -[NSRunLoop(NSRunLoop) run] + 76
15 MyApp 0x000000010f9e30b8 +[GAI threadMain:] + 62
16 Foundation 0x0000000114543aeb __NSThread__start__ + 1047
17 libsystem_pthread.dylib 0x00007fff51b3b109 _pthread_start + 148
18 libsystem_pthread.dylib 0x00007fff51b36b8b thread_start + 15
)
libc++abi.dylib: terminating with uncaught exception of type NSException
When I use version 6.0 of Google Tag Manager the app doesn't crash, but I can't use it cause I need some features of Firebase that require latests version of Firebase that is not compatible with Google Tag Manager 6.0当我使用 6.0 版的 Google 跟踪代码管理器时,应用程序不会崩溃,但我无法使用它,因为我需要 Firebase 的某些功能,这些功能需要与 Google 跟踪代码管理器 6.0 不兼容的最新版本 Firebase
How can I get rid of that crash?我怎样才能摆脱那次崩溃? thanks you in advance.
提前谢谢你。
Ok I found the solution for who have the same issue, remove "_" from the name of event, so I just replaced this line:好的,我找到了有相同问题的解决方案,从事件名称中删除“_”,所以我只是替换了这一行:
Analytics.logEvent("open_screen", parameters: ["screenName": name])
with:和:
Analytics.logEvent("openScreen", parameters: ["screenName": name])
and it worked.它奏效了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.