gpt4 book ai didi

php - Firebase Api Key 仅不适用于 iOS

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:10:56 26 4
gpt4 key购买 nike

我想在 php 中使用 firebase 发送推送通知。我的代码适用于 android,但不适用于 ios 设备。

我在这两种情况下都取得了成功:1。

这是我的代码

<?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;
?>

响应是

stdClass Object
(
[multicast_id] => 8.5168949472892E+18
[success] => 1
[failure] => 0
[canonical_ids] => 0
[results] => Array
(
[0] => stdClass Object
(
[message_id] => 0:1493801065120413%2d69fd2bf9fd7ecd
)

)

)

最佳答案

从 iphone 中删除应用程序并重新安装,之后您将获得新的 firebase token 尝试再次发送推送。首先从 php 端进行调试,他们正在向更新的设备 token 发送推送。

关于php - Firebase Api Key 仅不适用于 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43755402/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com