Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 一起使用Google Analytics SDK和Firebase SDK_Ios_Objective C_Firebase_Google Analytics_Firebase Analytics - Fatal编程技术网

Ios 一起使用Google Analytics SDK和Firebase SDK

Ios 一起使用Google Analytics SDK和Firebase SDK,ios,objective-c,firebase,google-analytics,firebase-analytics,Ios,Objective C,Firebase,Google Analytics,Firebase Analytics,我的AppDelegate的didFinishLaunchingWithOptions方法中的[FIRApp configure]步骤发生崩溃 guard let gai = GAI.sharedInstance() else { assert(false, "Google Analytics not configured correctly") } gai.tracker(withTrackingId: "YOUR_TRACKING_ID") 撞车完全没有给我任何信息 但我也在我的应用程

我的AppDelegate的
didFinishLaunchingWithOptions
方法中的
[FIRApp configure]
步骤发生崩溃

guard let gai = GAI.sharedInstance() else {
  assert(false, "Google Analytics not configured correctly")
}
gai.tracker(withTrackingId: "YOUR_TRACKING_ID")
撞车完全没有给我任何信息

但我也在我的应用程序中使用Google Analytics SDK。也许这就是原因

所以我的问题是-是否可以在一个应用程序中同时使用Google Analytics和Firebase SDK


谢谢。

可以使用Google Analytics和Firebase Analytics,而不会出现任何问题

修复崩溃:

您需要从Firebase控制台下载
GoogleService Info.plist
,并将其添加到您的项目中。当您调用
[FIRApp configure]
时,它会尝试从此plist文件中读取与配置相关的数据。如果找不到它,您的计算机将崩溃

下载后,只需将其拖放到Xcode中的项目目录。这将初始化Firebase并阻止你的应用程序崩溃。

我解决了我的问题。 对于GA跟踪,我们应该在AppDelegate的
didFinishLaunchingWithOptions
方法中使用这行代码

guard let gai = GAI.sharedInstance() else {
  assert(false, "Google Analytics not configured correctly")
}
gai.tracker(withTrackingId: "YOUR_TRACKING_ID")
对于Firebase跟踪,我们应该使用

FirebaseApp.configure()

在同一个地方。 此方法是应用程序中Firebase初始化的默认方法。它从
GoogleService Info.plist
文件中获取初始化所需的所有数据,您应该从Firebase上的仪表板下载该文件。 它在我的第一步就崩溃了

所以实际问题是: 默认的
GoogleService Info.plist
文件不包括Firebase初始化所需的
TRACKING_ID
字段

解决方案:
只需将
TRACKING\u ID
属性添加到您的
GoogleService Info.plist
文件中。此属性的值应具有以下格式:UA-XXXXXXXX-XX

否:)GoogleService-Info.plist已在项目中,这不是崩溃的原因。是否检查了目标成员资格?还可以尝试清理生成文件夹。控制台日志中是否有相关信息?