Firebase无法运行iOS

时间:2017-05-18 22:02:40

标签: ios swift firebase firebase-analytics firebase-notifications

我已经检查了所有内容,所有内容似乎都已正确设置但我无法获得Firebase推送通知,分析和崩溃工作。数据库工作得很完美。

正确设置了应用ID,并上传了p12证书。我用OneSignal对此进行了测试,但通知工作正常。此外,应用程序功能设置正确。

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

谷歌.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 个答案:

答案 0 :(得分:0)

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

  

Google Analytics入门非常简单。只需将Firebase SDK添加到新的或现有的应用程序中,数据收集就会自动开始。您可以在几小时内在Firebase控制台中查看分析数据。