无法查看 Firebase Analytics 调试视图 React Native

Eri*_*ner 6 ios firebase react-native firebase-analytics react-native-firebase

我已经学习了多个教程并阅读了多个 Stackoverflow 帖子,但无论我做什么,我都无法使用 RNFireBase 在我的 iOS 应用程序的 DebugView 中显示任何内容。我真的很感激这方面的一些帮助。我已经失去了几天试图弄清楚这一点,但我不知道出了什么问题。我在模拟器和物理设备上都尝试过,但都没有运气。

我在 XCode 的控制台中收到日志消息,但在 Firebase 控制台中没有显示任何内容。以下是我在使用事件时在本地收到的消息:

反应本机

<TouchableOpacity
  onPress={() =>
    analytics().logSelectContent({
      content_type: "clothing",
      item_id: "abcd",
    })
  }
>
  <Text>Log message</Text>
</TouchableOpacity>;
Run Code Online (Sandbox Code Playgroud)

日志

2020-05-15 12:22:26.486761-0400 Example App[23464:8820959] 6.13.0 - [Firebase/Analytics][I-ACS023051] Logging event: origin, name, params: app, select_content, {
    content_type = clothing;
    ga_event_origin (_o) = app;
    ga_screen_class (_sc) = UIViewController;
    ga_screen_id (_si) = -3307323385789565728;
    item_id = abcd;
}
2020-05-15 12:22:26.487676-0400 Example App[23464:8820959] 6.13.0 - [Firebase/Analytics][I-ACS023073] Debug mode is enabled. Marking event as debug and real-time. Event name, parameters: select_content, {
    content_type = clothing;
    ga_debug (_dbg) = 1;
    ga_event_origin (_o) = app;
    ga_realtime (_r) = 1;
    ga_screen_class (_sc) = UIViewController;
    ga_screen_id (_si) = -3307323385789565728;
    item_id = abcd;
}
2020-05-15 12:22:26.500453-0400 Example App[23464:8820959] 6.13.0 - [Firebase/Analytics][I-ACS023072] Event logged. Event name, event params: select_content, {
    content_type = clothing;
    ga_debug (_dbg) = 1;
    ga_event_origin (_o) = app;
    ga_realtime (_r) = 1;
    ga_screen_class (_sc) = UIViewController;
    ga_screen_id (_si) = -3307323385789565728;
    item_id = abcd;
}
2020-05-15 12:22:26.502567-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS002002] Measurement timer scheduled to fire in approx. (s): 0.9828788042068481
2020-05-15 12:22:26.502616-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS023028] Upload task scheduled to be executed in approx. (s): 0.9828788042068481
2020-05-15 12:22:27.497172-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS002001] Measurement timer fired
2020-05-15 12:22:27.497304-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS002003] Measurement timer canceled
2020-05-15 12:22:27.497444-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS023033] Starting data upload
2020-05-15 12:22:27.501020-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS023105] Event is not subject to real-time event count daily limit. Marking an event as real-time. Event name, parameters: select_content, {
    content_type = clothing;
    ga_debug (_dbg) = 1;
    ga_event_origin (_o) = app;
    ga_realtime (_r) = 1;
    ga_screen_class (_sc) = UIViewController;
    ga_screen_id (_si) = -3307323385789565728;
    item_id = abcd;
}
2020-05-15 12:22:27.511485-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS012018] Saving bundle. size (bytes): 499
2020-05-15 12:22:27.512391-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS023116] Bundle added to the upload queue. BundleID, timestamp (ms): 38, 1589559746485
2020-05-15 12:22:27.518879-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS023038] Uploading events. Elapsed time since last successful upload (s): 44.21102094650269
2020-05-15 12:22:27.519180-0400 Example App[23464:8820960] 6.13.0 - [Firebase/Analytics][I-ACS023039] Measurement data sent to network. Timestamp (ms), data: 1589559747518, <APMPBMeasurementBatch: 0x2808513f0>
2020-05-15 12:22:27.524885-0400 Example App[23464:8820960] 6.13.0 - [Firebase/Analytics][I-ACS900000] Uploading data. Host: https://app-measurement.com/a
2020-05-15 12:22:27.607462-0400 Example App[23464:8820960] 6.13.0 - [Firebase/Analytics][I-ACS901006] Received SSL challenge for host. Host: https://app-measurement.com/a
2020-05-15 12:22:27.674761-0400 Example App[23464:8821408] 6.13.0 - [Firebase/Analytics][I-ACS023044] Successful upload. Got network response. Code, size: 204, -1
2020-05-15 12:22:27.679982-0400 Example App[23464:8821408] 6.13.0 - [Firebase/Analytics][I-ACS002002] Measurement timer scheduled to fire in approx. (s): -0.1942161321640015
2020-05-15 12:22:27.680071-0400 Example App[23464:8821408] 6.13.0 - [Firebase/Analytics][I-ACS023028] Upload task scheduled to be executed in approx. (s): -0.1942161321640015
2020-05-15 12:22:27.688291-0400 Example App[23464:8821408] 6.13.0 - [Firebase/Analytics][I-ACS023024] No data to upload. Upload task will not be scheduled
2020-05-15 12:22:27.688364-0400 Example App[23464:8821408] 6.13.0 - [Firebase/Analytics][I-ACS002003] Measurement timer canceled
Run Code Online (Sandbox Code Playgroud)

这是我所做的一切:

我修改了我的 AppDelegate.m

// imports
#import <Firebase.h> // Imported Firebase.h
// more imports

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    if ([FIRApp defaultApp] == nil) {
        [FIRApp configure];
    }
// ... rest of my didFinishLaunchingWithOptions
Run Code Online (Sandbox Code Playgroud)

我将 GoogleService-Info.plist 添加到我的应用程序目标中。然后我关注了这篇文章,并:

现在这并不重要,但对于在这个问题上出错的人来说仍然很重要。由于 GoogleServices-Info.plist 文件中的问题,firebase 分析的调试模式有时不起作用 只需进行这 2 个更改。

将 IS_ANALYTICS_ENABLED 设置为 YES

将 FIREBASE_ANALYTICS_COLLECTION_DEACTIVATE 设置为 NO

在此处输入图片说明

FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED完全移除

然后FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED我像这篇文章建议的那样从我的 .plist 中删除。还是行不通。

确保没有OS_ACTIVITY_MODE:disable这篇文章所说的那样启用

如果您在某个时候添加了 OS_ACTIVITY_MODE:disable,请确保从项目方案中的环境变量中删除它。

设置环境变量

在此处输入图片说明

Podfile.lock 相关部分

- Firebase/Analytics (6.13.0):
    - Firebase/Core
  - Firebase/Core (6.13.0):
    - Firebase/CoreOnly
    - FirebaseAnalytics (= 6.1.6)
  - Firebase/CoreOnly (6.13.0):
    - FirebaseCore (= 6.4.0)
  - FirebaseAnalytics (6.1.6):
    - FirebaseCore (~> 6.4)
    - FirebaseInstanceID (~> 4.2)
    - GoogleAppMeasurement (= 6.1.6)
    - GoogleUtilities/AppDelegateSwizzler (~> 6.0)
    - GoogleUtilities/MethodSwizzler (~> 6.0)
    - GoogleUtilities/Network (~> 6.0)
    - "GoogleUtilities/NSData+zlib (~> 6.0)"
    - nanopb (= 0.3.9011)
  - FirebaseCore (6.4.0):
    - FirebaseCoreDiagnostics (~> 1.0)
    - FirebaseCoreDiagnosticsInterop (~> 1.0)
    - GoogleUtilities/Environment (~> 6.2)
    - GoogleUtilities/Logger (~> 6.2)
  - FirebaseCoreDiagnostics (1.2.4):
    - FirebaseCoreDiagnosticsInterop (~> 1.2)
    - GoogleDataTransportCCTSupport (~> 3.0)
    - GoogleUtilities/Environment (~> 6.5)
    - GoogleUtilities/Logger (~> 6.5)
    - nanopb (~> 0.3.901)
  - FirebaseCoreDiagnosticsInterop (1.2.0)
  - FirebaseInstanceID (4.2.7):
    - FirebaseCore (~> 6.0)
    - GoogleUtilities/Environment (~> 6.0)
    - GoogleUtilities/UserDefaults (~> 6.0)
Run Code Online (Sandbox Code Playgroud)

小智 10

我遇到了同样的问题并设法通过

  1. 像使用 -FIRDebugEnabled 一样设置环境变量。

  2. 我没有在 react native 中运行应用程序(例如:yarn run ios/android),而是直接在 Xcode 中运行。(如果您通过 react native 运行,它也不会出现在我的调试视图中)。

  3. 然后设备会神奇地出现在调试视图中。我没有按照您提到的任何其他步骤进行操作。在此处输入图片说明

这是我的版本以防万一。如果还没有解决,希望对你有所帮助。


"react-native": "^0.63.2",
"@react-native-firebase/app": "^8.4.7",
"@react-native-firebase/analytics": "^7.6.9",

Run Code Online (Sandbox Code Playgroud)