【发布时间】:2017-06-07 10:36:20
【问题描述】:
我能够获得消息 ID 作为回报,但通知未显示在 android 设备中,但从 firebase 控制台运行良好,我可以从 firebase 控制台发送到主题“nadakko”
<?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
【问题讨论】:
标签: android firebase firebase-cloud-messaging