如何在不迁移到Firebase的情况下获取google-services.json文件

4

我目前正在开发一个安卓项目。所以我使用Google云消息传递来实现推送通知,并且我需要将另一个应用添加到gcm中,因此我需要google-services.json文件来实现gcm服务,但是现在谷歌说我必须先在Firebase上注册并迁移,然后才能获取google-services.json文件。我不想使用Firebase的原因是我必须根据Firebase修改所有网络服务。有其他方法可以做到这一点吗?

我有很多类似这样的方法。

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);
}  
  }
1个回答

0

我正在迁移到Firebase,只是为了下载google-services.json文件,而不需要更改任何Web服务和Android项目,这样就可以正常工作了。


Android和Web服务仍在使用GCM。 - g03r03

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接