在更新了Android和flutter (和kotlin)之后,我得到了以下警告/错误
如何解决或我可以忽略没有相应的错误?
非常感谢。
W/FlutterJNI(23046): FlutterJNI.loadLibrary called more than once
W/FlutterJNI(23046): FlutterJNI.prefetchDefaultFontManager called more than once
W/FlutterJNI(23046): FlutterJNI.init called more than once
编辑23.03.2022:
这是因为“等待Firebase.initializeApp()”被调用了两次,类似于前面提到的文档。我得做更多的研究。也许用firebase_options.dart解决。
编辑16.04.2022:
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform,);
}
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform,);
// Set the background messaging handler early on, as a named top-level function
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
//String? token =
await FirebaseMessaging.instance.getAPNSToken();
await FirebaseMessaging.instance.getToken();
//print('APNS token: $token');
}
发布于 2022-04-07 12:46:16
我也面临着同样的错误。此消息显示如果您多次调用FirebaseMessaging.instance
。例如:
final _firebaseMessaging = FirebaseMessaging.instance
await _firebaseMessaging.requestPermission(
announcement: true,
carPlay: true,
criticalAlert: true,
);
await
FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
alert: true,
badge: true,
sound: true,
);
在这里,FirebaseMessaging.instance
被调用了两次。通过将FirebaseMessaging.instance
转换为_firebaseMessaging
来解决问题。希望这能帮上忙。
注意:不要在不同的文件中使用FirebaseMessaging.instance
,或者通过传递初始化的文件来使用它。
https://stackoverflow.com/questions/71514802
复制相似问题