Firebase InstanceID.instanceID().token() method is deprecated
InstanceID
is now deprecated. Try
Messaging.messaging().token { token, error in
// Check for error. Otherwise do what you will with token here
}
See Documentation on Fetching the current registration token
Fetching the current registration token
Registration tokens are delivered via the method
messaging:didReceiveRegistrationToken:
. This method is called generally once per app start with an FCM token. When this method is called, it is the ideal time to:
- If the registration token is new, send it to your application server.
- Subscribe the registration token to topics. This is required only for new subscriptions or for situations where the user has re-installed the app.
You can retrieve the token directly using
instanceIDWithHandler:
. This callback provides anInstanceIDResult
, which contains the token. A non null error is provided if the InstanceID retrieval failed in any way.
You should import FirebaseInstanceID
import FirebaseInstanceID
objective C
on your getTokenMethod
[[FIRInstanceID instanceID] instanceIDWithHandler:^(FIRInstanceIDResult * _Nullable result,
NSError * _Nullable error) {
if (error != nil) {
NSLog(@"Error fetching remote instance ID: %@", error);
} else {
NSLog(@"Remote instance ID token: %@", result.token);
}
}];
Swift
InstanceID.instanceID().instanceID { result, error in
if let error = error {
print("Error fetching remote instange ID: \(error)")
} else if let result = result {
print("Remote instance ID token: \(result.token)")
}
}
Update
InstanceID
is now deprecated. Try
Messaging.messaging().token { token, error in
// Check for error. Otherwise do what you will with token here
}
Here the solution
The problem is that FirebaseInstanceID has recently become deprecated
Old
InstanceID.instanceID().instanceID {result, _ in
New
Messaging.messaging().token { (token, _) in
You can replace it like above, it working
Check below link
https://medium.com/nerd-for-tech/how-to-solve-capacitor-error-no-such-module-firebaseinstanceid-9c142933b589