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

    2. <small id='2aTPm'></small><noframes id='2aTPm'>

      • <bdo id='2aTPm'></bdo><ul id='2aTPm'></ul>
      <legend id='2aTPm'><style id='2aTPm'><dir id='2aTPm'><q id='2aTPm'></q></dir></style></legend>

    3. 使用 PHP 的 Expo 推送通知

      时间:2023-10-10

    4. <legend id='8G8zy'><style id='8G8zy'><dir id='8G8zy'><q id='8G8zy'></q></dir></style></legend>

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

            <bdo id='8G8zy'></bdo><ul id='8G8zy'></ul>
            1. <small id='8G8zy'></small><noframes id='8G8zy'>

                <tfoot id='8G8zy'></tfoot>
                  <tbody id='8G8zy'></tbody>
                本文介绍了使用 PHP 的 Expo 推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试使用 PHP 向我的本机应用程序发送推送通知,下面的代码也发送了所有注册了他们的令牌的用户,虽然令牌是针对特定设备的,但它一次发送了大量通知,但它不断向所有人推送通知

                I am trying to send a Push Notification to my react native app using PHP, the below code is sending too all the users that registered their token and it sends plenty Notification at once though the token is for specific device but it keep pushing the notification to all

                $key = "ExponentPushToken[0GAEokJazChx21MOxeC1l2]";
                $title = "title";
                $interestDetails = ['https://exp.host/--/api/v2/push/send',$key];
                
                  try{
                
                      $expo = ExponentPhpSDKExpo::normalSetup();
                
                  // Subscribe the recipient to the server
                      $expo->subscribe($interestDetails[0], $interestDetails[1]);
                
                  // Build the notification data
                
                    $notification = ['title' => $title,'body' => $msg];
                
                  // Notify an interest with a notification
                   $expo->notify($notification);
                
                  $status = 'success';
                }catch(Exception $e){
                
                
                
                }
                
                
                   ?>
                

                我尝试如下更改我的代码

                I tried changing my code as follow

                <?php
                
                $key = "ExponentPushToken[0GAEokJazChx21MOxeC1l2]";
                $title = "title";
                
                
                  try{
                
                      $expo = ExponentPhpSDKExpo::normalSetup();
                
                
                
                  // Build the notification data
                
                  $notification = ['to' => $key,'title' => $title,'body' => $msg];
                
                  // Notify an interest with a notification
                 $expo->notify('https://exp.host/--/api/v2/push/send',$notification);
                
                  $status = 'success';
                }catch(Exception $e){
                    echo $e;
                }
                
                
                
                
                  echo $status;
                
                
                  ?>
                

                它确实发送给了特定用户,但仍然一次发送大量通知?

                It did sent to a specific user but still it keeps sending plenty notification at once?

                推荐答案

                试试这个

                $key = "ExponentPushToken[0GAEokJazChx21MOxeC1l2]";
                $userId = 'userId from your database';
                $notification = ['title' => $title,'body' => $msg];
                  try{
                
                      $expo = ExponentPhpSDKExpo::normalSetup();
                      $expo->notify($userId,$notification);//$userId from database
                      $status = 'success';
                }catch(Exception $e){
                        $expo->subscribe($userId, $key); //$userId from database
                        $expo->notify($userId,$notification);
                        $status = 'new subscribtion';
                }
                
                  echo $status;
                  ?>
                

                这篇关于使用 PHP 的 Expo 推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:有没有办法在windows和linux上使用php检测文件夹中的变化? 下一篇:Laravel:在 DB::transaction() 中使用 try...catch

                相关文章

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

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

                  1. <legend id='o0hxb'><style id='o0hxb'><dir id='o0hxb'><q id='o0hxb'></q></dir></style></legend>
                  2. <tfoot id='o0hxb'></tfoot>
                    • <bdo id='o0hxb'></bdo><ul id='o0hxb'></ul>