iOS 应用程序中的“Firebase Messaging getToken() 错误:获取响应无效,需要‘令牌’或‘错误’密钥”

问题描述 投票:0回答:1

我在 Flutter iOS 应用中尝试使用 Firebase Messaging 获取令牌时遇到错误。错误信息如下:

FLTFirebaseMessaging: An error occurred while calling method Messaging#getToken, errorOrNil => {    NSLocalizedFailureReason = "Invalid fetch response, expected 'token' or 'Error' key";}

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: [firebase_messaging/unknown] An unknown error has occurred.
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
<asynchronous suspension>
#2      MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:534:43)
<asynchronous suspension>
#3      MethodChannelFirebaseMessaging.getToken (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:248:11)
<asynchronous suspension>
#4      FCMToken.getFcm (package:instahire/firebase/fcm_token.dart:5:21)
<asynchronous suspension>
#5      SplashController.getToken (package:instahire/controllers/splash_controller.dart:42:23)
<asynchronous suspension>

昨天还好好的,突然就出现这个错误了。 怎么解决这个问题?

ios flutter xcode
1个回答
0
投票

钥匙好像不见了,

  1. 确保您已将
    GoogleService-Info.plist
    添加到您的项目中
  2. 在询问令牌之前请检查您是否已致电
    FirebaseApp.configure()
© www.soinside.com 2019 - 2024. All rights reserved.