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

标签 android ios firebase push-notification

我想通过我的服务器向 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/

相关文章:

android - 使用 adb shell 命令测试应用程序,即使其中一个测试失败,如何让它继续?

android - Dreamweaver CS 5.5 Android 错误 - 包 com.phonegap 不存在

ios - 检测来自哪个识别器的手势

ios - 如何用 %d 本地化 stringWithFormat?

json - Firebase 数据库 : How to save a list of friends per user?

swift - 类型 'FirebaseAuth' 没有成员 'showTextInputPrompt'

java - Android ListView 删除所有内容后仍然包含一项

android - 如何在 flexbox-layout 中改变项目的方向

ios - 有什么方法可以从后台跟踪当前正在运行的应用程序?

java - Firebase 中的设备到设备通知错误 token 编号