No visible @interface for 'FIRInstanceID' declares the selector 'setAPNSToken:type:'

Viewed 9254

after updating Pod library getting above error in appdelegate.m

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {

    [[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeSandbox];
    NSString *newToken = [deviceToken description];
    newToken = [newToken stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
    newToken = [newToken stringByReplacingOccurrencesOfString:@" " withString:@""];
    NSLog(@"My token is: %@", newToken);

}
3 Answers

It is deprecated code, you should try with the FIRMessaging

You can update your code to look like this

// With "FirebaseAppDelegateProxyEnabled": NO
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [FIRMessaging messaging].APNSToken = deviceToken;
}

Refer here for more details.

You probably have an old version of firebase_messaging in your pubspec.yaml. Make sure you have the latest version. If this does not help, go to the ios folder (cd ios/), then run pod update, and then flutter clean. Then, run your app again.

Alternative solutions: Probably it is a problem with latest firebase version (v6). Change firebase version in Podfile. add below line to Podfile

pod 'Firebase/Core', '~>5.20.2'

Then run pod update

This help me fixed problem

Related