error: no such module 'FirebaseInstanceID' on ios
Solution 1
updated 19/07/2021
remove the FirebaseInstanceID and install Firebase Messaging latest version..
i later solve the issue by installing Firebase Messaging Plugin
Solution 2
FirebaseInstanceID is deprecated now, that is why this error is coming. Remove import FirebaseInstanceID
from your AppDelegate.swift
and instead add import FirebaseMessaging
because FCM token is now provided directly on the Messaging instance. Now replace the code of InstanceID
in didRegisterForRemoteNotificationsWithDeviceToken
with this
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
Messaging.messaging().token { (token, error) in
if let error = error {
print("Error fetching remote instance ID: \(error.localizedDescription)")
} else if let token = token {
print("Token is \(token)")
}
}
}
Gbenga B Ayannuga
Hello! I'm Ayannuga Gbenga, a software developer based in Nigeria, Lagos. I enjoy creating Mobile/Web applications, including backend services and integration with external systems. My goal is to build user friendly and performant applications.
Updated on November 27, 2022Comments
-
Gbenga B Ayannuga over 1 year
i am trying to run my code and keep telling me
error: no such module 'FirebaseInstanceID' import FirebaseInstanceID
my code in AppDelegate.swift
import UIKit import Flutter import Firebase import FirebaseAuth import UserNotifications import FirebaseInstanceID @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { let firebaseAuth = Auth.auth() firebaseAuth.setAPNSToken(deviceToken, type: AuthAPNSTokenType.unknown) } override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { let firebaseAuth = Auth.auth() if (firebaseAuth.canHandleNotification(userInfo)){ print(userInfo) return } } }
i think is missing in my pod, i did not no how to install it to my pod file.