我想在运行 flutter for web 时添加 Firefox 作为默认浏览器(chrome 的某些软件包有错误)。我之前在 Ubuntu 20.4 上做过这个,但我已经切换到 arch 并且我不记得我是如何做到的。
所以我更新了firebase_messaging并且我不得不更改我的代码,因为FirebaseMessagin.configure()它已被弃用,现在当我收到通知并单击通知时,它不会打开另一个屏幕。
这就是我实现通知的方式:
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
print('Handling a background message ${message.messageId}');
}
const AndroidNotificationChannel channel = AndroidNotificationChannel(
'high_importance_channel', // id
'High Importance Notifications', // title
'This channel is used for important notifications.', // description
importance: Importance.high,
);
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'e-R?d?u?i',
debugShowCheckedModeBanner: false,
initialRoute: …Run Code Online (Sandbox Code Playgroud) android push-notification flutter remote-notifications firebase-cloud-messaging