Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

}
like image 682
SM18 Avatar asked Oct 31 '18 07:10

SM18


2 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.

like image 171
Bhavin Kansagara Avatar answered Oct 05 '22 21:10

Bhavin Kansagara


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.

like image 31
Moritz Morgenroth Avatar answered Oct 05 '22 21:10

Moritz Morgenroth