You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter iOS端获取FCM Token及订阅Topic失败问题求助

Flutter iOS端FCM Token获取失败问题

Flutter iOS应用无法获取FCM Token,导致iOS用户无法接收推送通知。

报错信息

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:648: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      main (package:sjdvs/main.dart:77:19)
<asynchronous suspension>


**Same Error for Messaging#subscribeToTopic
FLTFirebaseMessaging: An error occurred while calling method Messaging#subscribeToTopic, 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.

已尝试的操作

  • 更新所有Firebase依赖
  • 执行flutter clean
  • 通过pod install --repo-update重装iOS Pods

预期应用能像Android端一样正常获取FCM Token,但返回错误:"Invalid fetch response, expected 'token' or 'Error' key"

环境信息

  • Flutter版本: 3.22.1(稳定通道)
  • firebase_messaging: ^15.1.3
  • firebase_core: ^3.6.0
  • firebase_storage: ^12.3.4
  • cloud_firestore: ^5.4.4
  • iOS部署目标: iOS 14.0
  • Xcode版本: 15.4

内容的提问来源于stack exchange,提问作者Kavita Patel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 16:07:32