iOS Google 跟踪代码管理器在启动时崩溃 'NSParseErrorException',原因:'Last tag: 116 should be 124'

iOS Google Tag Manager crashing upon Launch with 'NSParseErrorException', reason: 'Last tag: 116 should be 124'

我们的其他 3 个 iOS 应用程序中有 Google 带有 Google 标签管理器 运行 的分析,但由于某些原因,这个最新的应用程序在尝试打开时崩溃容器。

这是有问题的代码行(类似于 GTM's guidelines):

        NSTimeInterval timeout = 0.1;
        [TAGContainerOpener openContainerWithId:containerName
                                     tagManager:_tagManager
                                       openType:kTAGOpenTypePreferNonDefault
                                        timeout:&timeout
                                       notifier:self];

抛出的错误:

Terminating app due to uncaught exception 'NSParseErrorException', 
reason: 'Last tag: 116 should be 124'

堆栈跟踪:

*** First throw call stack:
(
    0   CoreFoundation                      0x0000000104dffa75 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000104716bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x0000000104dff9ad +[NSException raise:format:] + 205
    3   MyApp                             0x0000000102831ce6 -[TAGPBCodedInputStream readUnknownGroup:builder:] + 152
    4   MyApp                             0x0000000102844904 -[TAGPBUnknownFieldSet mergeFieldFrom:input:] + 283
    5   MyApp                             0x000000010283ceb1 -[TAGPBGeneratedMessage parseUnknownField:extensionRegistry:tag:] + 203
    6   MyApp                             0x000000010283cfc8 -[TAGPBGeneratedMessage mergeFromCodedInputStream:extensionRegistry:] + 264
    7   MyApp                             0x000000010283cb35 -[TAGPBGeneratedMessage mergeFromData:extensionRegistry:] + 88
    8   MyApp                             0x000000010283cc1e +[TAGPBGeneratedMessage parseFromData:extensionRegistry:] + 82
    9   MyApp                             0x0000000102852da7 -[TAGResourceStorageImpl loadResourceFromContainerFile:] + 352
    10  MyApp                             0x000000010284d245 -[TAGContainer createInitialContainer] + 89
    11  MyApp                             0x000000010284afd3 -[TAGContainer initWithId:tagManager:resourceStorage:] + 399
    12  MyApp                             0x000000010284b098 -[TAGContainer initWithId:tagManager:] + 112
    13  MyApp                             0x000000010284ffe5 -[TAGManager containerById:] + 64
    14  MyApp                             0x000000010284f618 -[TAGManager openContainerById:callback:] + 258
    15  MyApp                             0x000000010284e9d3 -[TAGContainerOpener openWithRefreshType:] + 850
    16  MyApp                             0x000000010284e5c5 +[TAGContainerOpener openContainerWithId:tagManager:openType:timeout:notifier:] + 155
    17  MyApp                             0x0000000102812588 -[AnalyticsManager initWithTrackingId:containerName:] + 776
    18  MyApp                             0x00000001027b5afe -[TIXAppDelegate setupAnalytics] + 94

到目前为止,我似乎无法在网上搜索任何信息。到目前为止,我唯一看到的是 GA's Release notes 中提到他们可能已弃用 openContainerWithId,但他们当前的指南对此或使用什么没有任何说明。

容器文件内容如下:

{
    "exportFormatVersion": 1.3,
    "exportTime": "2015-06-23 16:11:59",
    "containerVersion": {
        "accountId": "197720",
        "containerId": "1300316",
        "containerVersionId": "0",
        "deleted": false,
        "container": {
            "accountId": "197720",
            "containerId": "1300316",
            "name": "App",
            "publicId": "GTM-MYCONTAINER",
            "timeZoneCountryId": "US",
            "timeZoneId": "America/Los_Angeles",
            "notes": "",
            "usageContext": [
                "IOS"
            ],
            "fingerprint": "1434997566330",
            "enabledBuiltInVariable": [
                "EVENT",
                "APP_ID",
                "APP_NAME",
                "APP_VERSION_CODE",
                "APP_VERSION_NAME"
            ]
        },
        "fingerprint": "0",
        "variable": [
            {
                "accountId": "197720",
                "containerId": "1300316",
                "variableId": "1",
                "name": "UA Number",
                "type": "c",
                "parameter": [
                    {
                        "type": "TEMPLATE",
                        "key": "value",
                        "value": "UA-TrackingNumber"
                    }
                ],
                "fingerprint": "0"
            },
            {
                "accountId": "197720",
                "containerId": "1300316",
                "variableId": "3",
                "name": "screen-from",
                "type": "v",
                "parameter": [
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "screen-from"
                    }
                ],
                "fingerprint": "0"
            },
            {
                "accountId": "197720",
                "containerId": "1300316",
                "variableId": "2",
                "name": "screen-name",
                "type": "v",
                "parameter": [
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "screen-name"
                    }
                ],
                "fingerprint": "0"
            },
            {
                "accountId": "197720",
                "containerId": "1300316",
                "variableId": "4",
                "name": "view-name",
                "type": "v",
                "parameter": [
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "view-name"
                    }
                ],
                "fingerprint": "0"
            }
        ]
    }
}

感谢任何帮助。

事实证明,如果没有在 Google 标签管理器的服务器端创建实际标签,就会发生此问题。

我们的分析人员最终做了以下事情: 1.在服务器上创建需要的标签 2. 生成我们在代码中更新的新容器文件

然后崩溃消失了,一切正常。