我已经尝试了下面的代码,看来我还需要做一些事情。我正在使用flutter_local_notification。我需要包括firebase吗?这是我的代码
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
class NotificationApi {
static final _notifications = FlutterLocalNotificationsPlugin();
static Future _notificationDetails() async {
return NotificationDetails(
android: AndroidNotificationDetails(
'com.example.gym',
'goal_channel',
importance: Importance.max,
),
iOS: IOSNotificationDetails(),
);
}
static Future showNotification({
int id = 0,
String? title,
body,
payload,
}) async =>
_notifications.show(
id,
title,
body,
await _notificationDetails(),
payload: payload,
);
}