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

5

在更新了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);

}
3个回答

7

这是过时的代码,你应该尝试使用 FIRMessaging

你可以将你的代码更新为如下格式

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

更多详细信息请参见此处


1
你的 pubspec.yaml 中可能有旧版本的 firebase_messaging。请确保你拥有最新版本。如果这没有帮助,请前往 ios 文件夹 (cd ios/),然后运行 pod update,再运行 flutter clean。然后重新启动应用程序。

0

替代解决方案: 可能是最新的 Firebase 版本(v6)出现了问题。请在 Podfile 中更改 Firebase 版本。 将以下行添加到 Podfile 中。

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

然后运行pod update

这帮助我解决了问题


使用 pod install 而不是 pod update。 - Jordan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接