我有这段代码:
push.on('notification', function(data) {
cordova.plugins.notification.local.schedule({
id: 1,
title: data.title,
style: "inbox",
icon: "res://ic_local_taxi_white_48dp",
smallIcon: "res://ic_local_taxi_white_48dp",
led: "FF0000" })});
以下数据被发送给它:
$msg = [
'body' => $message,
'title' => $title,
"content-available" => "1",
'sound' => "default",
'icon' => 'ic_local_taxi_white_48dp'
];
$fields = [
'to' => $key,
'priority' => 5,
'data' => $msg,
'notification' => NULL
];
content-availble 标头确保它push.on在后台运行,但是,android 本身也会显示来自自身的第二个通知。如何确保 android 不会重复一条消息?我需要用按钮显示通知,为此我使用 push.on 方法中的构造函数
解决方案是删除 title & body & message 字段并通过任何其他方式发送数据。你可以从
data.additionalData.name