【问题标题】:Google Tag Manager with Firebase crash iOS带有 Firebase 的 Google 跟踪代码管理器崩溃 iOS
【发布时间】:2020-04-29 20:17:03
【问题描述】:

我在我的应用中使用 Google 跟踪代码管理器和 Firebase。

这是我记录屏幕和事件的代码:

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])
    }
}

当我启动我的应用程序时,我遇到了这个崩溃:

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

当我使用 6.0 版 Google 跟踪代码管理器时,该应用不会崩溃,但我无法使用它,因为我需要 Firebase 的某些功能,这些功能需要最新版本的 Firebase,但与 Google 跟踪代码管理器 6.0 不兼容

我怎样才能摆脱那次崩溃?提前谢谢你。

【问题讨论】:

标签: ios firebase google-tag-manager


【解决方案1】:

好的,我找到了有相同问题的解决方案,从事件名称中删除“_”,所以我只是替换了这一行:

Analytics.logEvent("open_screen", parameters: ["screenName": name])

与:

Analytics.logEvent("openScreen", parameters: ["screenName": name])

它成功了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-14
    • 1970-01-01
    • 2017-12-20
    • 2016-01-21
    • 2013-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多