有没有一种方法可以通过从 Flutter 中的通知中滑动来停止警报声
Is there a way to stop alarm sound by swiping from notification in Flutter
我想在通知来的时候叫闹钟。我做到了,但我没有通过滑动通知来停止警报。这是我的代码示例:
Future<void> _messageHandler(RemoteMessage message) async {
debugPrint('Incoming notification is ${message.notification!.body}');
FlutterRingtonePlayer.playAlarm(asAlarm: false);
//FlutterRingtonePlayer.stop();
}
void main() async{
HttpOverrides.global = new MyHttpOverrides();
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FirebaseMessaging.onBackgroundMessage(_messageHandler);
runApp(MyApp());
}
因此,有什么办法可以解决这个问题吗?我在等你的想法,谢谢...
Future<void> _messageHandler(RemoteMessage message) async {
debugPrint('Incoming notification is ${message.notification!.body}');
FlutterRingtonePlayer.playAlarm(asAlarm: false);
debugPrint('afterPlay');
Future.delayed(const Duration(seconds: 15), () {
FlutterRingtonePlayer.stop();
});
debugPrint('afterStop');
}
我想在通知来的时候叫闹钟。我做到了,但我没有通过滑动通知来停止警报。这是我的代码示例:
Future<void> _messageHandler(RemoteMessage message) async {
debugPrint('Incoming notification is ${message.notification!.body}');
FlutterRingtonePlayer.playAlarm(asAlarm: false);
//FlutterRingtonePlayer.stop();
}
void main() async{
HttpOverrides.global = new MyHttpOverrides();
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FirebaseMessaging.onBackgroundMessage(_messageHandler);
runApp(MyApp());
}
因此,有什么办法可以解决这个问题吗?我在等你的想法,谢谢...
Future<void> _messageHandler(RemoteMessage message) async {
debugPrint('Incoming notification is ${message.notification!.body}');
FlutterRingtonePlayer.playAlarm(asAlarm: false);
debugPrint('afterPlay');
Future.delayed(const Duration(seconds: 15), () {
FlutterRingtonePlayer.stop();
});
debugPrint('afterStop');
}