Google Firebase通知不能订阅主题


Google Firebase notifications can't subscribe topics

我有一个新的firebase应用程序。目的是从php服务器到iOS设备发送通知到主题。

我已经成功地测试了一切,直到从服务器向特定设备id发送通知。

然而,话题拒绝友好。

从PHP端:

function call_firebase_notification ($signal){ 
    $to = "/topics/demo";
    $title = "php function test real";
    $body = "php function test real body";
    $payload = json_encode(array(
                    "to" => $to ,
                    "notification" => array(
                      "title" => $title,
                      "body" => $body
                    )
                ));
    $headers = array(
        "Authorization: key=AIzaSyBr0G...Euxr5x4_0",
        "Content-Type: application/json",
        "Content-Length: ". strlen($payload)
        );
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, "https://fcm.googleapis.com/fcm/send"); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);    
    $return = curl_exec($ch); 
    curl_close($ch);
    return $return;
}
$return = call_firebase_notification("test");
var_dump($return);

我得到一个最正的结果:string(34)message_id"{:9067338503195970026}"

iOS端:

[[FIRMessaging messaging] subscribeToTopic:@"/topics/demo"];

我现在的犯罪伙伴也说在订阅时得到了积极的结果。

但是没有通知到达(再次注意:当发送到他的id时通知成功交付),并且当尝试从firebase控制台发送通知时没有出现主题。

编辑:(对自己和世界的提醒)

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

永远不要使用这些,除非绝对必要或无聊到你的头,这是一个演示片段,所以我真的不关心,但通常你应该更新你的SSL证书

请尝试在通知有效载荷上添加prioritycontent_available参数。

{
  "to": "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
  "notification": {
     "title": "test",
     "body": "my message"
  },
  "priority": "high",
  "content_available": true
}

我还注意到昨天Firebase cloud Messaging中的服务中断

答案其实很简单:时间。在我的情况下,大约是2天,但在那之后,主题的通知随机工作正常。