[英]How to run push notifications loop in the background laravel?
現在,我需要在每個記錄添加上向所有用戶發送FCM推送通知,但是要花很長時間遍歷所有用戶,如何使循環在后台工作?
我正在使用brozot / Laravel-FCM軟件包
您可能正在觸發推送通知事件。 因此,在觸發推送通知事件時,您可以將通知推送到隊列中。 此隊列基本上在Listeners文件夾中聲明的類中實現。 例:
namespace App\Listeners;
use App\Events\EventName;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\FcmAdapter;
class NotificationClassName implements ShouldQueue
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param EventName $event
* @return void
*/
public function handle(EventName $event)
{
// code for sending FCM notification.
}
}
實現ShouldQueue是實現隊列的方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.