I'm using Google Tag Manager with Firebase in my app.
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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.