Flutter 关闭应用程序时不显示颤振通知

Flutter 关闭应用程序时不显示颤振通知,flutter,firebase-cloud-messaging,Flutter,Firebase Cloud Messaging,所以我通过PHP发送fcm $msg = array ( 'badge' => '1', 'body' => $notificationBody, 'tag' => "185", 'title' => $notificationTitle, 'icon' =>

所以我通过PHP发送fcm

            $msg = array
            (
                'badge' => '1',
                'body' => $notificationBody,
                'tag' => "185",
                'title' => $notificationTitle,
                'icon' => 'myicon',
                'sound' => 'mySound',
                'priority' => 'high',
                'show_in_foreground' => True,
                'click_action' => 'FLUTTER_NOTIFICATION_CLICK',
            );

    $fields = array
            ( 'to' => $toNotification,
              'notification' => $msg );

    $headers = array
            (
                'Authorization: key=MyKEEEy',
                'Content-Type: application/json'
            );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
    $result = curl_exec($ch);
    print_r($result);
    curl_close($ch);
现在,即使我没有打开应用程序,它也可以在android上运行。但当我在ios模拟器上尝试时,通知只在我打开应用程序时显示

我的颤振锉刀

    _fcm.configure(
      onMessage: (Map<String, dynamic> message) async {
        setState(() {
          _counter++;
        });
        showDialog(
          context: context,
          builder: (context) => AlertDialog(
            content: ListTile(
              title: Text(message['notification']['title']),
              subtitle: Text(message['notification']['body']),
            ),
            actions: <Widget>[
              FlatButton(
                child: Text('Ok'),
                onPressed: () {
                  Navigator.of(context).pop();
                  setState(() {
                    _counter = _counter - 1;
                  });
                },
              ),
            ],
          ),
        );
      },
      onLaunch: (Map<String, dynamic> message) async {
        print("launch");
      },
      onResume: (Map<String, dynamic> message) async {
        print("resume");
      },
    );
\u fcm.configure(
onMessage:(映射消息)异步{
设置状态(){
_计数器++;
});
显示对话框(
上下文:上下文,
生成器:(上下文)=>AlertDialog(
内容:ListTile(
标题:文本(消息['notification']['title']),
字幕:文本(消息['notification']['body']),
),
行动:[
扁平按钮(
子项:文本('Ok'),
已按下:(){
Navigator.of(context.pop();
设置状态(){
_计数器=_计数器-1;
});
},
),
],
),
);
},
onLaunch:(映射消息)异步{
打印(“发布”);
},
onResume:(映射消息)异步{
打印(“简历”);
},
);
我已经在firebase上添加了apn密钥


我怎样才能修好它?我错过了什么吗?

iOS模拟器没有接收推送通知。您必须在实际设备上运行

我对php通知不太了解,但我已经通过node.js函数解决了这个问题,所以您想将node函数放在google firebase函数中,然后您应该查看它