Expo Push Notification with PHP

后端 未结 2 1296
别跟我提以往
别跟我提以往 2021-01-13 21:01

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 Notific

2条回答
  •  春和景丽
    2021-01-13 21:12

    Try this

    $key = "ExponentPushToken[0GAEokJazChx21MOxeC1l2]";
    $userId = 'userId from your database';
    $notification = ['title' => $title,'body' => $msg];
      try{
    
          $expo = \ExponentPhpSDK\Expo::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;
      ?>
    

提交回复
热议问题