php - 如何将带有 NotificationPusher 组件的自定义有效负载参数发送到苹果设备?
问题描述
我正在努力使用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'
]
]);
将有效负载中的自定义参数通过推送消息发送到苹果设备的确切语法是什么?
解决方案
我已经在 github 上挖掘了源代码,发现数组的“自定义”键不是由 ASPN 适配器提取的。
但是我找到了一段提取完整“消息”数组的代码,所以我的猜测是在“消息”部分中添加“自定义”数组,这也是我的问题的解决方案。
$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'
]
]
]);
推荐阅读
- android - 浓缩咖啡测试:未正确设置 TestNavHostController.setCurrentDestination
- xslt - 如何使用 XSLT 将一个文档中的特定文本提取到一个新文档中?
- typescript - 如何支持类 mixin 的对象合并
- postgresql - 两列 A 和 B,表 Y (A, B) 参考表 X (A, B)。当 Y 中的 A 发生变化时,如何使 Y 中的 B 更改为引用的表 X 值?
- flutter - 如何在flutter中验证号码电话的身份验证后停止登录
- javascript - 创建用户控件
- mysql - MySQL 链式替换?
- flutter - 我想在 statefulWidget 中使用 bloc 获取发布数据数据已准备好我不会从 api 获取它 oi 怎么做?
- python - Django:如何通过views.py中的OneToOne关系访问模型字段?
- azure - Azure 数据工厂 - 如果在数据库表中找不到文件,则复制活动