<tfoot id='2JVJP'></tfoot>
  1. <small id='2JVJP'></small><noframes id='2JVJP'>

    1. <legend id='2JVJP'><style id='2JVJP'><dir id='2JVJP'><q id='2JVJP'></q></dir></style></legend>
      <i id='2JVJP'><tr id='2JVJP'><dt id='2JVJP'><q id='2JVJP'><span id='2JVJP'><b id='2JVJP'><form id='2JVJP'><ins id='2JVJP'></ins><ul id='2JVJP'></ul><sub id='2JVJP'></sub></form><legend id='2JVJP'></legend><bdo id='2JVJP'><pre id='2JVJP'><center id='2JVJP'></center></pre></bdo></b><th id='2JVJP'></th></span></q></dt></tr></i><div id='2JVJP'><tfoot id='2JVJP'></tfoot><dl id='2JVJP'><fieldset id='2JVJP'></fieldset></dl></div>

      • <bdo id='2JVJP'></bdo><ul id='2JVJP'></ul>

      如何在 PHP 中使用 fcm(firebase 控制台)向 iphone 发送推送通知?

      时间:2024-08-22

            • <i id='11Li4'><tr id='11Li4'><dt id='11Li4'><q id='11Li4'><span id='11Li4'><b id='11Li4'><form id='11Li4'><ins id='11Li4'></ins><ul id='11Li4'></ul><sub id='11Li4'></sub></form><legend id='11Li4'></legend><bdo id='11Li4'><pre id='11Li4'><center id='11Li4'></center></pre></bdo></b><th id='11Li4'></th></span></q></dt></tr></i><div id='11Li4'><tfoot id='11Li4'></tfoot><dl id='11Li4'><fieldset id='11Li4'></fieldset></dl></div>

              <small id='11Li4'></small><noframes id='11Li4'>

                <bdo id='11Li4'></bdo><ul id='11Li4'></ul>

                  <tbody id='11Li4'></tbody>
                <legend id='11Li4'><style id='11Li4'><dir id='11Li4'><q id='11Li4'></q></dir></style></legend><tfoot id='11Li4'></tfoot>
                本文介绍了如何在 PHP 中使用 fcm(firebase 控制台)向 iphone 发送推送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                从 firebase 控制台发送通知时,通知工作正常.

                While sending the notification from firebase console Notification is working fine.

                我在 ios 设备上收到推送通知.

                I am getting push notifications on ios device.

                这是我用来使用 FCM 在 php 中向 iphone 发送推送通知的代码..

                Here is the code that I am using to send push notifications to iphone in php using FCM..

                <?php  $ch = curl_init("https://fcm.googleapis.com/fcm/send");
                
                    //The device token.
                    $token = "";
                
                    //Title of the Notification.
                    $title = "Carbon";
                
                    //Body of the Notification.
                    $body = "Bear island knows no king but the king in the north, whose name is stark.";
                
                    //Creating the notification array.
                    $notification = array('title' =>$title , 'text' => $body);
                
                    //This array contains, the token and the notification. The 'to' attribute stores the token.
                    $arrayToSend = array('to' => $token, 'notification' => $notification);
                    //Generating JSON encoded string form the above array.
                    $json = json_encode($arrayToSend);
                
                    //Setup headers:
                    $headers = array();
                    $headers[] = 'Content-Type: application/json';
                    $headers[] = 'Authorization: key= abcdgfdk'; //server key here
                
                    //Setup curl, add headers and post parameters.
                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
                    curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
                    curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);       
                
                    //Send the request
                    $response = curl_exec($ch);
                
                    //Close request
                    curl_close($ch);
                    return $response; ?>
                

                它返回以下响应:

                {"multicast_id":7847791275395796141,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1473926169782959%51b989d251b989d2"}]}
                

                请告诉我我做错了什么?我也为 android 使用相同的代码及其服务器密钥和设备令牌,它工作正常......

                Please suggest me what I am doing wrong? I use same code for android too with its server key and device token and it is working fine...

                推荐答案

                谢谢 shubank .. 你的答案有效... 我唯一需要添加的是优先级高... 这是更新的代码... 可以也帮助别人:)

                Thanks shubank .. your answer works... The only thing I need to add is priority high... Here is the updated code... May it help someone too :)

                 $ch = curl_init("https://fcm.googleapis.com/fcm/send");
                
                    //The device token.
                    $token = ""; //token here
                
                    //Title of the Notification.
                    $title = "Carbon";
                
                    //Body of the Notification.
                    $body = "Bear island knows no king but the king in the north, whose name is stark.";
                
                    //Creating the notification array.
                    $notification = array('title' =>$title , 'text' => $body);
                
                    //This array contains, the token and the notification. The 'to' attribute stores the token.
                    $arrayToSend = array('to' => $token, 'notification' => $notification,'priority'=>'high');
                
                    //Generating JSON encoded string form the above array.
                    $json = json_encode($arrayToSend);
                    //Setup headers:
                    $headers = array();
                    $headers[] = 'Content-Type: application/json';
                    $headers[] = 'Authorization: key= $key'; // key here
                
                    //Setup curl, add headers and post parameters.
                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
                    curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
                    curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);       
                
                    //Send the request
                    $response = curl_exec($ch);
                
                    //Close request
                    curl_close($ch);
                    return $response;
                

                这篇关于如何在 PHP 中使用 fcm(firebase 控制台)向 iphone 发送推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何从网络向应用发送 FCM 通知 下一篇:通过 cURL/PHP 发送时设备上未收到 Firebase 通知

                相关文章

                  <legend id='DEikv'><style id='DEikv'><dir id='DEikv'><q id='DEikv'></q></dir></style></legend>

                    <small id='DEikv'></small><noframes id='DEikv'>

                    • <bdo id='DEikv'></bdo><ul id='DEikv'></ul>
                  1. <tfoot id='DEikv'></tfoot>

                  2. <i id='DEikv'><tr id='DEikv'><dt id='DEikv'><q id='DEikv'><span id='DEikv'><b id='DEikv'><form id='DEikv'><ins id='DEikv'></ins><ul id='DEikv'></ul><sub id='DEikv'></sub></form><legend id='DEikv'></legend><bdo id='DEikv'><pre id='DEikv'><center id='DEikv'></center></pre></bdo></b><th id='DEikv'></th></span></q></dt></tr></i><div id='DEikv'><tfoot id='DEikv'></tfoot><dl id='DEikv'><fieldset id='DEikv'></fieldset></dl></div>