gpt4 book ai didi

android - Android 和 IOS 上的 Firebase 推送通知有问题吗?

转载 作者:行者123 更新时间:2023-11-29 06:00:53 24 4
gpt4 key购买 nike

我想通过我的服务器向 Android 和 Ios 操作系统上的用户发送通知。我使用curl来发送消息,它看起来像这样:

$fields = array(
'condition' => $cond,
'priority' => 'high',
'content_available' => true,
'notification' => $message['data'],
'data' => $message
);

如果我从服务器请求中完全删除通知字段。仅发送 data 字段并在 onMessageReceived() 中处理它,然后我在Android操作系统上很好地收到了通知数据,但在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

关于android - Android 和 IOS 上的 Firebase 推送通知有问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54682655/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com