小编Mud*_*sir的帖子

WebPush gmp 扩展未加载,但需要使用 payload 发送推送通知。您可以在 php.ini 中修复此问题

我正在使用 webpush 处理通知。我使用链接来实现通知网络推送。我正在搜索并应用上周的每个解决方案,但同样的问题我安装了 gmp 并在 xampp/etc/php.ini 中添加

extension = mcrypt.so
Run Code Online (Sandbox Code Playgroud)

这是我的代码

class InvoicePaid extends Notification implements ShouldQueue
{
    use Queueable;
    public $title, $body;
    public function __construct($title, $body)
    {
        //
        $this->title = $title;
        $this->body = $body;
    }
    public function via($notifiable)
    {
        return [WebPushChannel::class];
    }

    public function toWebPush($notifiable, $notification)
    {
        $time = \Carbon\Carbon::now();
        return WebPushMessage::create()
            // ->id($notification->id)
            ->title($this->title)
            ->icon(url('/push.png'))
            ->body($this->body);
        //->action('View account', 'view_account');
    }
}
Run Code Online (Sandbox Code Playgroud)

我的路线是

Route::post('/send-notification/{id}', function($id, Request $request){
    $user = \App\User::findOrFail($id);
    $user->notify(new \App\Notifications\GenericNotification($request->title, $request->body));
    return response()->json([
        'success' => …
Run Code Online (Sandbox Code Playgroud)

php notifications push-notification laravel web-push

5
推荐指数
1
解决办法
5042
查看次数