对于flutter_local_notifications的iOS设置,需要为IOSInitializationSettings添加onDidReceiveLocalNotification,但是示例代码不是开箱即用的,如何正确修复?
void onDidReceiveLocalNotification(
int id, String title, String body, String payload) async { // How to pass id, title, body and payload
showDialog(
context: context, // How to get the context of dialog?
builder: (BuildContext context) => CupertinoAlertDialog(
title: Text(title),
content: Text(body),
actions: [
CupertinoDialogAction(
isDefaultAction: true,
child: Text('Ok'),
onPressed: () async {
Navigator.of(context, rootNavigator: true).pop();
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SecondScreen(payload),
),
);
},
)
],
),
);
}