2017-09-25 85 views
0

我想使用FCM爲Android,iOS和Web構建聊天應用程序。我希望我的郵件能夠存儲在我的服務器中,所以我的想法是將郵件從我的應用程序發送到我的服務器,然後從我的服務器發送到使用Firebase的其他應用程序用戶。我發現這個方法(https://firebase.google.com/docs/cloud-messaging/http-server-ref)發送消息,但我的問題是,消息是否會傳遞到我的應用程序使用xmpp?會有任何額外的延遲來傳遞訊息嗎?我可能會與50位參與者聊天,這會是一個問題嗎?使用HTTP協議發送Firebase雲消息

+0

即使您擁有數千名參與者或數百萬人,您也不會遇到任何問題,而且您不必執行任何其他操作,如執行xmpp或其他任何操作r協議firebase和谷歌管理這一點。 –

+0

不會有任何延遲。有兩種協議可以使用:HTTP或XMPP –

回答

0

可以用PHP,捲曲發短信

function sendGCM($message, $id) { 


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

    $fields = array (
      'registration_ids' => array (
        $id 
      ), 
      'data' => array (
        "message" => $message 
      ) 
    ); 
    $fields = json_encode ($fields); 

    $headers = array (
      'Authorization: key=' . "YOUR_KEY_HERE", 
      'Content-Type: application/json' 
    ); 

    $ch = curl_init(); 
    curl_setopt ($ch, CURLOPT_URL, $url); 
    curl_setopt ($ch, CURLOPT_POST, true); 
    curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers); 
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields); 

    $result = curl_exec ($ch); 
    echo $result; 
    curl_close ($ch); 
} 

?> 

$消息是你的消息發送到設備

$ id是器械註冊令牌

YOUR_KEY_HERE是你的服務器API密鑰(或傳統服務器API密鑰)

相關問題