如何将带有通知推送器组件的自定义负载参数发送到苹果设备?
How can I send custom payload paramter with the NotificationPusher component to apple devices?
我正在为 NotificationPusher 组件的使用和将有效负载中的自定义参数发送到苹果产品的可能性而苦苦挣扎。
我尝试了以下方法,因为我在 github 上的文档中找到了这个注释。
$message = new Message("Hello there", [
'message' => [
'sound' => 'default'
],
'custom' => [
'lat' => 123,
'lon' => 321,
'radius' => 32,
'date' => date('Y-m-d H:i:s'),
'action' => 'update'
]
]);
遗憾的是,这种语法没有产生预期的结果。苹果设备不会收到这些参数。
我也试过这个,但是也失败了。
$message = new Message("Hello there", [
'message' => [
'sound' => 'default',
'custom_lat' => 123,
'custom_lon' => 321,
'custom_radius' => 32,
'custom_date' => date('Y-m-d H:i:s'),
'custom_action' => 'update'
]
]);
使用推送消息将负载中的自定义参数发送到 Apple 设备的确切语法是什么?
我仔细研究了 github 上的源代码,发现数组的 'custom' 键没有被 ASPN 适配器提取。
但是我找到了一段提取完整 'message' 数组的代码,所以我的猜测是在 'message' 部分添加 'custom' 数组,然后呢是我的问题的解决方案。
$message = new Message("Hello there", [
'message' => [
'sound' => 'default',
'custom' => [
'lat' => 123,
'lon' => 321,
'radius' => 32,
'date' => date('Y-m-d H:i:s'),
'action' => 'update'
]
]
]);
我遇到了同样的需求。开始调试,发现KhorneHoly是对的:你需要在custom
键下发送payload。不过数组格式有点不同:
$message = new Message('This is the message', [
'custom'=> [
'payloadKey' => 'payloadContent'
]
]);
我正在使用 "sly/notification-pusher": "^2.3"
希望对您有所帮助=)
我正在为 NotificationPusher 组件的使用和将有效负载中的自定义参数发送到苹果产品的可能性而苦苦挣扎。
我尝试了以下方法,因为我在 github 上的文档中找到了这个注释。
$message = new Message("Hello there", [
'message' => [
'sound' => 'default'
],
'custom' => [
'lat' => 123,
'lon' => 321,
'radius' => 32,
'date' => date('Y-m-d H:i:s'),
'action' => 'update'
]
]);
遗憾的是,这种语法没有产生预期的结果。苹果设备不会收到这些参数。
我也试过这个,但是也失败了。
$message = new Message("Hello there", [
'message' => [
'sound' => 'default',
'custom_lat' => 123,
'custom_lon' => 321,
'custom_radius' => 32,
'custom_date' => date('Y-m-d H:i:s'),
'custom_action' => 'update'
]
]);
使用推送消息将负载中的自定义参数发送到 Apple 设备的确切语法是什么?
我仔细研究了 github 上的源代码,发现数组的 'custom' 键没有被 ASPN 适配器提取。
但是我找到了一段提取完整 'message' 数组的代码,所以我的猜测是在 'message' 部分添加 'custom' 数组,然后呢是我的问题的解决方案。
$message = new Message("Hello there", [
'message' => [
'sound' => 'default',
'custom' => [
'lat' => 123,
'lon' => 321,
'radius' => 32,
'date' => date('Y-m-d H:i:s'),
'action' => 'update'
]
]
]);
我遇到了同样的需求。开始调试,发现KhorneHoly是对的:你需要在custom
键下发送payload。不过数组格式有点不同:
$message = new Message('This is the message', [
'custom'=> [
'payloadKey' => 'payloadContent'
]
]);
我正在使用 "sly/notification-pusher": "^2.3"
希望对您有所帮助=)