'FIRInstanceID'的可见@interface没有声明选择器'setAPNSToken:type:'

SM1*_*M18 4 ios firebase firebase-cloud-messaging

更新Pod库后,出现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);

}
Run Code Online (Sandbox Code Playgroud)

Bha*_*ara 5

它已过时,您应该尝试使用 FIRMessaging

您可以将代码更新为如下所示

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

有关更多详细信息,请参见此处