在将 Firebase pod 更新到 6.0.1 后,当我尝试构建使用 Firebase Messaging 的 iOS 版本的 Flutter 应用程序时出现问题。我从不使用 Objecrtive C,这就是为什么这个错误令人困惑
我可以通过注释掉导致问题的行来让它工作。我不确定将这段代码用于生产有多重要。
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
#ifdef DEBUG
[[FIRMessaging messaging] setAPNSToken:deviceToken type:FIRMessagingAPNSTokenTypeSandbox];
#else
[[FIRMessaging messaging] setAPNSToken:deviceToken type:FIRMessagingAPNSTokenTypeProd];
#endif
//[_channel invokeMethod:@"onLaunch" arguments:_launchNotification];
[_channel invokeMethod:@"onToken" arguments:[[FIRInstanceID instanceID] token]];
}
预期结果只是构建应用程序,但我收到错误。
最佳答案
您使用的 firebase_messaging
包版本可能已过时。目前,当前版本是 firebase_messaging 7.0.3
.根据您发布此问题的日期,我认为您使用的是 firebase_messaging 5.0.1+1
.
此外,this GitHub issue 之一有一些解决方法。
- 如前所述,不要使用过时版本的 firebase_messaging 包。使用它的最新版本。
pod更新
在项目的ios文件夹中- 运行
flutter clean
如果这不起作用,请尝试至少提供一个 minimal, reproducible example产生问题的代码以及运行 flutter doctor
时的结果。
关于objective-c - 如何修复 : "No visible @interface for ' FIRInstanceID' declares the selector 'token' "in iOS build in Flutter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56259457/