我正在使用 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)