gpt4 book ai didi

ios - Firebase 无法在 iOS 上运行

转载 作者:行者123 更新时间:2023-11-30 12:27:04 26 4
gpt4 key购买 nike

我已经检查了所有内容,所有内容似乎都已正确设置,但我无法让 Firebase 推送通知、分析和崩溃正常工作。不过数据库运行得很好。

应用 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:.
}


}

最佳答案

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

Getting started with Analytics is easy. Just add the Firebase SDK to your new or existing app, and data collection begins automatically. You can view analytics data in the Firebase console within hours.

关于ios - Firebase 无法在 iOS 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44058436/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com