showNotification method
Future<bool>
showNotification({
- required int id,
- String? title,
- String? body,
- required String channelId,
- required String channelName,
- String? payload,
- String? largeIcon,
- String? bigPicture,
- String? smallIcon,
- String? visibility,
- String? accentColor,
- List<
Map< ? buttons,String, String?> >
override
Post a notification from native code (used to render foreground pushes on
Android, since FCM does not draw one while the app is open). Returns true
if it was shown. No-op / false where unsupported. payload is stashed on
the tap intent and delivered back via onNotificationTap.
Implementation
@override
Future<bool> showNotification({
required int id,
String? title,
String? body,
required String channelId,
required String channelName,
String? payload,
String? largeIcon,
String? bigPicture,
String? smallIcon,
String? visibility,
String? accentColor,
List<Map<String, String?>>? buttons,
}) async {
try {
final ok = await methodChannel.invokeMethod<bool>('showNotification', {
'id': id,
'title': title,
'body': body,
'channelId': channelId,
'channelName': channelName,
'payload': payload,
'largeIcon': largeIcon,
'bigPicture': bigPicture,
'smallIcon': smallIcon,
'visibility': visibility,
'accentColor': accentColor,
'buttons': buttons,
});
return ok ?? false;
} catch (_) {
return false;
}
}