簡體   English   中英

如何在不遷移到firebase的情況下獲取google-services.json

[英]How to get google-services.json without migrating to firebase

目前我正在開發一個android項目。 所以即時通訊使用谷歌雲消息進行推送通知,我必須添加另一個應用程序到gcm所以我想google-services.json .json文件的gcm服務,但現在谷歌說首先我必須在firebase上注冊並遷移它然后我可以得到 google-services.json文件。 我不想要firebase base的原因是我必須根據firebase修改所有webservice。 這樣做還有其他辦法嗎?

我有這么多方法。

public function send_message($gcm_id,$details){

$reg_token = array($gcm_id);

$msg =array("message"=>$details);

//Creating a new array fileds and adding the msg array and registration token array here 
$fields = array
(
    'registration_ids'  => $reg_token,
    'data'          => $msg
);

//Adding the api key in one more array header 
$headers = array
(
    'Authorization: key= MY_API_KEY',
    'Content-Type: application/json'
); 

//Using curl to perform http request 
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );


//Getting the result 
$result = curl_exec($ch );
curl_close( $ch );

//Decoding json from result 
$res = json_decode($result);


//Getting value from success 
$flag = $res->success;

//if success is 1 means message is sent \
$response = array("error" => FALSE);
if($flag == 1){
    //Redirecting back to our form with a request success 
     $response["error"] = false;
    $response["error_msg"] = "Message SuccessFully Sent Check Your Device";
     echo json_encode($response);

}else{
    //Redirecting back to our form with a request failure 
    $response["error"] = TRUE;
    $response["error_msg"] = "Eror Occured";

    echo json_encode($response);
}  
  }

我正在遷移到firebase只是為了下載google-services.json而不改變webservice和android項目上的任何東西,它的工作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM