【问题标题】:Cannot receive firebase analytics from IOS无法从 IOS 接收 Firebase 分析
【发布时间】:2021-09-21 08:58:55
【问题描述】:

我正在为 Android 和 IOS 开发 Flutter 应用程序。我正在使用 firebase_analytics 8.2.0 包收集分析。

我已经按照包documentation 中的说明配置了我的应用程序。我的Podfile$FirebaseAnalyticsWithoutAdIdSupport = true 开头。

问题是我只能接收 Android 分析。

我的代码:

final FirebaseAnalytics analytics = FirebaseAnalytics();

void onGroupCreate(String groupId, double totalInvites, bool isStatus) {
      analytics.logEvent(
        name: "create_group",
        parameters: <String, dynamic>{
          'user_id': globals.user.userId,
          'group_id': groupId,
          'total_invites': totalInvites,
          'is_status': isStatus
        },
      );
    }

我的info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>AppName</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>AppName</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(MARKETING_VERSION)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>com.googleusercontent.apps.####-#######</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>$(CURRENT_PROJECT_VERSION)</string>
    <key>FirebaseAppDelegateProxyEnabled</key>
    <false/>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSContactsUsageDescription</key>
    <string>This app requires contacts access to function properly.</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>This app requires photos access to function properly.</string>
    <key>UIBackgroundModes</key>
    <array>
        <string>fetch</string>
        <string>remote-notification</string>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
</dict>
</plist>

我的GoogleService-Info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CLIENT_ID</key>
    <string>####-######.apps.googleusercontent.com</string>
    <key>REVERSED_CLIENT_ID</key>
    <string>com.googleusercontent.apps.####-######</string>
    <key>ANDROID_CLIENT_ID</key>
    <string>####-######.apps.googleusercontent.com</string>
    <key>API_KEY</key>
    <string>####-######</string>
    <key>GCM_SENDER_ID</key>
    <string>####</string>
    <key>PLIST_VERSION</key>
    <string>1</string>
    <key>BUNDLE_ID</key>
    <string>######</string>
    <key>PROJECT_ID</key>
    <string>####-####</string>
    <key>STORAGE_BUCKET</key>
    <string>####-####.appspot.com</string>
    <key>IS_ADS_ENABLED</key>
    <false></false>
    <key>IS_ANALYTICS_ENABLED</key>
    <false></false>
    <key>IS_APPINVITE_ENABLED</key>
    <true></true>
    <key>IS_GCM_ENABLED</key>
    <true></true>
    <key>IS_SIGNIN_ENABLED</key>
    <true></true>
    <key>GOOGLE_APP_ID</key>
    <string>#:####:ios:######</string>
    <key>DATABASE_URL</key>
    <string>https://####-####.firebaseio.com</string>
</dict>
</plist>

什么会导致这个问题?为什么我无法接收 IOS 分析?

【问题讨论】:

  • GoogleService-Info.plist 文件中找到的应用程序的所有值都正确吗?
  • 我已经将firebase_analytics 示例的GoogleService-Info.plist 文件(github.com/FirebaseExtended/flutterfire/blob/master/packages/…)与我的文件进行了比较,它们都是相同的。
  • 我还再次下载了我的GoogleService-Info.plist 并将其与我当前的GoogleService-Info.plist 文件进行了比较。唯一的变化是ANDROID_CLIENT_ID 不同。有关系吗?

标签: ios flutter firebase-analytics


【解决方案1】:

Firebase 事件会一起批处理并每小时上传一次,以防止设备过度消耗电池电量。 在 iOS 上,当您在 1h 上传目标之前后台应用程序时,此时将在后台调度事件。 上传事件后,数据将在 Firebase Analytics 仪表板中显示之前大约有 3 小时的延迟。此外,默认日期范围不包括“今天”,因此您只能看到昨天的事件。

在某些情况下,您需要在真实设备上运行它并等待 24 小时才能在控制台中看到您的应用

您可以使用debug view 来测试您的事件

【讨论】:

  • 您好@Omar Mahmoud,感谢您的回复。该应用程序在物理设备上运行已经一个多星期了。此外,我还使用调试视图测试了该应用程序。没有结果:\
  • 您在调试视图中看到事件了吗??
  • 没什么。我还向 Flutterfire 团队提出了一个问题 github.com/FirebaseExtended/flutterfire/issues/…
  • 您是否删除了 $FirebaseAnalyticsWithoutAdIdSupport = true 只是为了测试?
  • 不,我没有,flutterfire 团队说没关系
【解决方案2】:

我认为您的代码没有任何问题。您能否检查一下您是否正确添加了 iOS App Store id 和 bundle Id?因为当我更改 App Store id 并且分析停止工作时,我曾经遇到过同样的问题。 附上截图供大家参考

【讨论】:

  • @Mirnal Jail 感谢您的回复。我已验证我的 App Store ID 与 appStoreConnect 上的 ID 相同。您认为我还应该验证什么?
【解决方案3】:

问题解决了!

问题在于我的项目分析属性中没有 IOS 数据流。我所要做的就是添加一个新的 IOS 数据流,然后等待一两天后分析结果出现。

在 GA4 分析上创建新数据流的步骤

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-27
    • 1970-01-01
    • 1970-01-01
    • 2016-11-10
    • 1970-01-01
    • 2021-06-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多