Skip to content

Failed to get instance FirebaseID #181

@grigala

Description

@grigala

Hi all,

We are experiencing a weird token retrieval issue with error Failed to get instance FirebaseID when calling FCM.getToken() on iOS. Coming from:

call.reject("Failed to get instance FirebaseID", error.localizedDescription)

Does anybody have an idea what can be the cause of this error(I understand it could be many things) and is there anything that can be done?

The Android at the same time has no issue, only iOS it getting the error.

The AppDelegate.swift file is configured according to documentation https://capacitorjs.com/docs/guides/push-notifications-firebase#ios:

import UIKit
import Capacitor
import FirebaseCore
import FirebaseMessaging

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?

  //... other methods ...

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    FirebaseApp.configure()
    return true
  }

  func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    Messaging.messaging().apnsToken = deviceToken
    Messaging.messaging().token(completion: { (token, error) in
      if let error = error {
          NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
      } else if let token = token {
          NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: token)
      }
    })
  }

  func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
  }

With Podfile correctly containing FirebaseMessaging pod dependency:

target 'App' do
  capacitor_pods
  # Add your Pods here
  pod 'FirebaseMessaging'
end

Could it be that we are still missing something in the configuration and thus Firebase not getting instantiated properly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions