【问题标题】:Problem with push notification with firebase on Android and IOS?Android 和 IOS 上的 firebase 推送通知有问题吗?
【发布时间】:2019-02-14 03:10:46
【问题描述】:

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

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

如果我从我的服务器请求中完全删除 通知 字段。仅发送 data 字段并在 onMessageReceived() 中处理它, 然后我很好地得到了Android OS的通知数据,但是没有收到IOS操作系统的通知。 但是,如果我完全从我的服务器请求中添加 notification 字段。 IOS操作系统收到好的通知,然后Android操作系统仍然收到通知但没有收到onMessageReceived()中的数据

我希望两种操作系统都能接收通知和数据

【问题讨论】:

    标签: android ios firebase push-notification


    【解决方案1】:

    您必须同时发送通知和数据。否则,它将无法正常工作。我不知道怎么做 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-18
      • 1970-01-01
      • 2014-05-24
      • 1970-01-01
      • 1970-01-01
      • 2018-06-18
      • 1970-01-01
      相关资源
      最近更新 更多