php - Firebase Api Key 仅适用于 iOS
<p><p>我想在 php 中使用 firebase 发送推送通知。我的代码适用于 android,但不适用于 ios 设备。</p>
<p>我在这两种情况下都取得了成功:1。</p>
<p><strong>这是我的代码</strong></p>
<pre><code><?php
$path_to_firebase_cm = 'https://fcm.googleapis.com/fcm/send';
$fields = array('registration_ids' => $token,
'data' =>array('title'=>'Title',
'body'=>$message['message'],
'image'=>$imagepath,
'priority'=>'high'
)
);
$headers = array(
'Authorization:key=AIzaSyBiOCXbU7roG59_**********vWa4Xc' ,
'Content-Type:application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $path_to_firebase_cm);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
curl_close($ch);
return $result;
?>
</code></pre>
<p><strong> react 是</strong> </p>
<pre><code>stdClass Object
(
=> 8.5168949472892E+18
=> 1
=> 0
=> 0
=> Array
(
=> stdClass Object
(
=> 0:1493801065120413%2d69fd2bf9fd7ecd
)
)
)
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>从 iphone 中删除应用程序并重新安装,之后您将获得新的 firebasetoken 尝试再次发送推送。
首先从 php 端调试它,他们正在发送更新的设备 token 上的推送。 </p></p>
<p style="font-size: 20px;">关于php - Firebase Api Key 仅适用于 iOS,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/43755402/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/43755402/
</a>
</p>
页:
[1]