gpt4 book ai didi

Xcode 控制台中显示 Firebase/InAppMessaging 错误

转载 作者:行者123 更新时间:2023-12-02 04:25:44 24 4
gpt4 key购买 nike

 pod 'Firebase/Database'
pod 'Firebase/InAppMessagingDisplay'
pod 'Firebase/Messaging'

为什么会出现这个错误?
我也正确阅读了文档和设置代码以及项目,但是当我从 firebase deshboard 发送 InAppMessaging 并打开应用程序时,我收到了这个错误。
[Firebase/InAppMessaging][I-IAM130004] Failed restful api request to fetch in-app messages: seeing http status code as 400 with body as {
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}


[Firebase/InAppMessaging][I-IAM700002] Error happened during message fetching Error Domain=NSURLErrorDomain Code=400 "(null)"

最佳答案

这背后有2-3个原因。

  • 未在 didFinishLaunchingWithOptions 处配置/初始化 Firebase
  • FCM token 过期或无效且未添加刷新 token 观察者
  • 使用无效/不同的 GoogleService-Info.plist
    即,如果您在 Dev 和 production 的同一项目中使用 2 GoogleService-Info.plist 。所以请确保在安装应用程序时正确的 GoogleService-Info.plist 正在获取

  • pod'Firebase/消息传递'
    如果您也使用 InAppMessagingDisplay,则也安装此 pod
    pod 'Firebase/InAppMessagingDisplay'
    在 didFinishLaunchingWithOptions 启动 Firebase
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    window = UIWindow(frame: CGRect(x: 0, y: 0, width: kDeviceWidth, height: kDeviceHeight))

    FirebaseApp.configure()
    NotificationCenter.default.addObserver(self, selector: #selector(tokenRefreshNotification), name: NSNotification.Name.InstanceIDTokenRefresh, object: nil)
    Messaging.messaging().delegate = self
    Messaging.messaging().shouldEstablishDirectChannel = true

    UNUserNotificationCenter.current().delegate = self

    if #available(iOS 10.0, *) {

    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()
    }
    // [START refresh_token]
    func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {

    //You save or send fcm token to your sever
    }


    //+++++++++++++++++++++++
    // FCM Token Get Refreshed
    @objc func tokenRefreshNotification(_ notification: Notification) {
    getFCMToken()
    }
    private func getFCMToken() {

    InstanceID.instanceID().instanceID { (result, error) in

    if error == nil {

    if let result = result {
    let fcmToken = result.token
    //Save or send to your server
    }
    }
    }
    }

    关于Xcode 控制台中显示 Firebase/InAppMessaging 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54586561/

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