android - Android 和 IOS 上的 firebase 推送通知有问题吗?
问题描述
我想通过我的服务器向 Android 和 Ios 操作系统上的用户发送通知。我使用 curl 发送消息,它看起来像这样:
$fields = array(
'condition' => $cond,
'priority' => 'high',
'content_available' => true,
'notification' => $message['data'],
'data' => $message
);
如果我从服务器请求中完全删除通知字段。仅发送数据字段并在 onMessageReceived() 中处理,然后我很好地收到了 Android OS 上的通知数据,但没有收到 IOS 操作系统上的通知。但是,如果我完全从我的服务器请求中添加通知字段。IOS操作系统收到好的通知,然后Android操作系统仍然收到通知但没有收到onMessageReceived()中的数据
我想要两种操作系统都能接收通知和数据的方法
解决方案
您必须同时发送通知和数据。否则,它将无法正常工作。我不知道怎么做 php 但我已经通过 api(postman).. 这是示例
{
"to" : "f77ydJXI- ps:APA91bFoueDSpV0ya8CngPxOFGG4nHjTGoYMv7Bl2pbu1f1",
"notification" : {
"click_action" : "Notification_activity",
"body" : "new Symulti update !",
"title" : "new Symulti update !",
"icon" : "ic_notification" },
"data" : {
"body" : "First Notification backgraound",
"title": "Collapsing A Backgraound",
"key_1" : "Okay this is test",
"key_2" : "4:24 pm 5/20/18"
}
}
您可以在此找到完整的示例
https://gist.github.com/Muhaiminur/f0d05f53fb2b0f5a6f3419c6514f0ca5
推荐阅读
- python - Python - 干净的代码,没有实现的异常?
- python - 如何通过按钮命令从 TkInter filedialog.askopenfile 获取文件名
- javascript - OpenLayers 在地图上放置一个多边形
- javascript - 将 PHP 数组传递给 AJAX(成功)函数
- python - 使用二分查找查找元素的最后位置
- swift - 如何使用 SwiftUI 从另一个 TabBarView 触发 TabBar 视图
- java - Java 等效于 C++ 的“std::string::find_first_not_of”
- java - “错误:本地主机上没有 Tomcat v9.0 的标签提供程序”
- python - Kivy 屏幕没有出现
- android - 将自定义视图添加到在 PDFTron.Android for Xamarin 中不起作用的页面