SM18
SM18

Reputation: 718

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

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);

}

Upvotes: 5

Views: 10029

Answers (3)

Moritz Morgenroth
Moritz Morgenroth

Reputation: 71

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.

Upvotes: 1

Nijat Aliyev
Nijat Aliyev

Reputation: 876

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

Upvotes: 0

Bhavin Kansagara
Bhavin Kansagara

Reputation: 2916

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.

Upvotes: 7

Related Questions