Firebase云消息传递消息ID显示但未接收通知

时间:2017-06-07 10:36:21

标签: android firebase firebase-cloud-messaging

我能够获得消息ID作为回报但是通知没有显示在Android设备中,但它在firebase控制台上工作正常,我可以发送到主题" nadakko"来自firebase控制台

     <?php
 $data = array(
           "message" => "sfsdgdgdfg"
          );
  $final = array(
            "condition" => "'nadakko' in topics",
            "data" => $data
           );

  $url = 'https://fcm.googleapis.com/fcm/send';

  $headers = array(
              'Authorization: key=AIzaSyAkjY4wwambC7ryNxr-KEjsx4VgSZuh-UY',
              'Content-Type: application/json'
             );
  // Open connection
  $ch = curl_init();

  // Set the url, number of POST vars, POST data
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  // Disabling SSL Certificate support temporarly
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($final));
  // Execute post
  $result = curl_exec($ch);

  if ($result === FALSE) {
      // curl failed
      echo "Faild";
  }
echo $result;
  // Close connection
  curl_close($ch);
  ?>

发送消息后我从android监视器收到此错误消息收到移动设备但有一些问题

06-07 18:06:16.139 8802-12118/info.***.*** E/MyFirebaseMessagingService: Data Payload: {message=sfsdgdgdfg}
06-07 18:06:16.139 8802-12118/info.**.**** E/MyFirebaseMessagingService: push json: {"message":"sfsdgdgdfg"}
06-07 18:06:16.139 8802-12118/info.**.*** E/MyFirebaseMessagingService: Json Exception: No value for data

2 个答案:

答案 0 :(得分:0)

06-07 18:06:16.139 8802-12118/info.**.*** E/MyFirebaseMessagingService: Json Exception: No value for data

这是问题所在,您需要阅读message而不是data 使用它将是

String message = json.getString("message");

答案 1 :(得分:0)

|  iID | iUserID | iDealID | iCategoryID | iSubCategoryID |    vType | eGainType | iLocationID |              dtAdded | eDeviceType | CustomType
|------|---------|---------|-------------|----------------|----------|-----------|-------------|----------------------|-------------|-------------
| 3410 |       1 |     389 |          79 |            135 | location |   Instant |        1403 | 2017-08-21T11:26:51Z |     Android | Unique
| 3412 |       1 |     389 |          79 |            135 |    gotit |   ByClick |           0 | 2017-08-21T11:27:19Z |     Android | Unique
| 3413 |       1 |     389 |          79 |            135 |    gotit |   ByClick |           0 | 2017-08-21T11:27:28Z |     Android | Repeat
| 3475 |     250 |     389 |          79 |            135 | location |   Instant |        1403 | 2017-08-21T12:55:34Z |     Android | Unique
| 3477 |     250 |     389 |          79 |            135 |    gotit |   ByClick |           0 | 2017-08-21T12:56:39Z |     Android | Unique
| 3479 |     250 |     389 |          79 |            135 |  website |   ByClick |           0 | 2017-08-21T13:04:30Z |     Android | Unique
| 3480 |     250 |     389 |          79 |            135 |  website |   ByClick |           0 | 2017-08-21T13:04:54Z |     Android | Repeat
| 3482 |     250 |     389 |          79 |            135 |    gotit |   ByClick |           0 | 2017-08-21T13:05:16Z |     Android | Repeat
| 3484 |       1 |     389 |          79 |            135 |  website |   ByClick |           0 | 2017-08-21T13:06:28Z |     Android | Unique
| 3485 |       1 |     389 |          79 |            135 |  website |   ByClick |           0 | 2017-08-21T13:06:36Z |     Android | Repeat