skip to Main Content

I’m encountering an error when trying to get the token using Firebase Messaging in my Flutter iOS app. The error message is as follows:

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>

Till yesterday it was working fine suddenly this error occurred.
How to solve this?

3

Answers


  1. Looks like the key is missing,

    1. Ensure that you have added GoogleService-Info.plist to you project
    2. Check that you called FirebaseApp.configure() before asking the token
    Login or Signup to reply.
  2. Try this command:

    1. Pod deintegrate
    2. Pod install

    And run the code.

    Login or Signup to reply.
  3. Yes, I have already added both things, but the same issue persists.Please let me know if there is anything I need to do because suddenly it stopped and I didn’t understand what went wrong.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search