Firebase 无法运行 iOS

Posted

技术标签:

【中文标题】Firebase 无法运行 iOS【英文标题】:Firebase not working iOS 【发布时间】:2017-05-18 22:02:40 【问题描述】:

我检查了一切,一切似乎都设置正确,但我无法让 Firebase 推送通知、分析和崩溃工作。该数据库虽然工作完美。

app id 设置正确,p12 证书上传。我用 OneSignal 对此进行了测试,尽管在那里通知工作正常。应用功能也设置正确。

我通过 cocoapods 将 firebase 添加到我的 xcode 项目中,并已更新到 V4.0(pod 更新)

正确添加了 google .plist 文件(或数据库无法工作)

当我最初将 firebase 添加到我的应用程序时,分析和通知确实有效,但它们非常延迟,统计数据只会在几小时后出现,但现在什么都没有出现。

这里是 AppDelegate.swift

import UIKit
import Firebase
import OneSignal

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate 

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool 
        // Override point for customization after application launch.



        OneSignal.initWithLaunchOptions(launchOptions, appId: "N/A")



        FirebaseApp.configure()

        if #available(ios 10.0, *) 
            // For iOS 10 display notification (sent via APNS)
            UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate

            let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
            UNUserNotificationCenter.current().requestAuthorization(
                options: authOptions,
                completionHandler: _, _ in )
         else 
            let settings: UIUserNotificationSettings =
                UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
            application.registerUserNotificationSettings(settings)
        

        application.registerForRemoteNotifications()






        return true
    

    func applicationWillResignActive(_ application: UIApplication) 
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    

    func applicationDidEnterBackground(_ application: UIApplication) 
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    

    func applicationWillEnterForeground(_ application: UIApplication) 
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    

    func applicationDidBecomeActive(_ application: UIApplication) 
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    

    func applicationWillTerminate(_ application: UIApplication) 
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    



【问题讨论】:

【参考方案1】:

您说数据显示较晚,因此这意味着它按预期正常工作(参见官方documentation)。

开始使用 Google Analytics(分析)很容易。只需将 Firebase SDK 添加到您的新应用或现有应用,数据收集就会自动开始。您可以在数小时内在 Firebase 控制台中查看分析数据。

【讨论】:

它曾经显示较晚(几个月前,当我第一次添加 SDK 时)现在根本不显示。 只有推送通知事件不显示或其他事件(first_open 或自定义事件)不显示?它多久前停止显示任何统计数据?您可以打开 DebugView 来查看实时调试事件以验证它是否正常工作,或者打开 StreamView 来查看过去 30 分钟内的真实用户数据。 好的,我做到了,现在分析正在运行,谢谢。推送通知仍然没有,通过 OneSignal 工作时有什么想法吗? 您是否尝试在他们的 github 帐户 github.com/firebase/quickstart-ios/issues 上查看 FCM 问题?我想你可以在那里找到一些相关的问题。

以上是关于Firebase 无法运行 iOS的主要内容,如果未能解决你的问题,请参考以下文章

无法为 Unity IOS 配置 Firebase 应用

iOS(2021)中的 Firebase crashlytics 脚本无法通过 Testflight 运行

在我的 iOS 应用程序中实施 pod 'Firebase/Firestore' 后无法运行应用程序

在 iOS 上退出 Google 登录无法在 Flutter Firebase 中运行

Firebase Crashlytics iOS:即使脚本似乎正在运行,也无法接收事件

无法在 iOS 中连接 firebase crashlytics