我正在使用 webpush 处理通知。我用过 this链接来实现通知网络推送。我正在搜索和应用上周的每个解决方案,但同样的问题
我安装了 gmp 并在 xampp/etc/php.ini 中添加
extension = mcrypt.so
这是我的代码
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');
}
}
我的路线是
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' => true
]);
});
但是当我发送通知时,我收到了这个错误
enter image description here
这是gmp安装的图片
最佳答案
试着去你的xampp/php/ext
文件夹
php_gmp.dll
存在xampp/php/php.ini
搜索
php_gmp
并确保它像 extension=php_gmp.dll
而不是 ;extension=php_gmp.dll
php_gmp.dll
到文件夹并重试该过程 您不应该再次遇到 gmp 问题。
关于php - 未加载 WebPush gmp 扩展,但需要使用 payload 发送推送通知。您可以在 php.ini 中修复此问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47234793/