InvalidRegistration在php中发送推送

时间:2018-06-27 12:09:40

标签: php firebase firebase-cloud-messaging

我试图在我的android应用上发送推送通知,但是我总是收到错误

  

“无效注册”

这是我在“ to

中发送的令牌

我的代码:-

fs = 4000;
L = 4000;
f = fs* ( 0 : (L / 2 )) / L;
for i = 1:2
  for j = 1:10
    fft_data=fft(vys_sig((4000*j)-3999:4000*j)); 
    subplot(2,1,1);
    a = gca();
    delete(a.children);
    plot(f,abs(fft_data(1:size(f, '*'))));
    subplot(2,1,2);
    plot(vysk_f);
    sleep(500);
  end
end

我的参数:

 public function android_push($token, $load, $key) {

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

    $fields = array(
        'registration_ids' => $token,
        'data' => $load
    );
    $headers = array(
        'Authorization: key=' . $key,
        '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_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields, true));
    $result = curl_exec($ch);
        if ($result === FALSE) {
        die('Curl failed: ' . curl_error($ch));
    }
    curl_close($ch);

结果:

  

{“ multicast_id”:4723735099133341876,“成功”:0,“失败”:1,“ canonical_ids”:0,“结果”:[{“错误”:“无效注册”}]}}

0 个答案:

没有答案