{"id":5404,"date":"2019-12-21T03:13:27","date_gmt":"2019-12-20T18:13:27","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=5404"},"modified":"2019-12-21T03:13:27","modified_gmt":"2019-12-20T18:13:27","slug":"%e5%8a%b9%e6%9e%9c%e7%9a%84%ef%bc%81laravel%e3%81%a7%e3%83%96%e3%83%a9%e3%82%a6%e3%82%b6%e3%81%ab%e3%83%97%e3%83%83%e3%82%b7%e3%83%a5%e9%80%9a%e7%9f%a5%e3%81%99%e3%82%8b%e6%a9%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=5404","title":{"rendered":"\u52b9\u679c\u7684\uff01Laravel\u3067\u30d6\u30e9\u30a6\u30b6\u306b\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3059\u308b\u6a5f\u80fd"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u9593\u306e<a href=\"https:\/\/blog.capilano-fw.com\/?p=5260\">\u30b3\u30d4\u30da\u3067OK\uff01Laravel\u304b\u3089wordpress\u306b\u6295\u7a3f\u3059\u308b\u6a5f\u80fd<\/a>\u3068\u3044\u3046\u8a18\u4e8b\u3067\u306fLaravel\u306b\u72ec\u81ea\u306e<code>Notification<\/code>\u3092\u4f5c\u3063\u3066<code>wordpress<\/code>\u306b\u6295\u7a3f\u3059\u308b\u6a5f\u80fd\u3092\u5b9f\u88c5\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u3053\u308c\u306b\u95a2\u9023\u3057\u3066<code>Notification<\/code>\u3067\u4ed6\u306b\u4f55\u304b\u3067\u304d\u306a\u3044\u304b\u3068\u8003\u3048\u3066\u3044\u305f\u3068\u3053\u308d\u3001\u3061\u3087\u3063\u3068\u624b\u9593\u304c\u5927\u304d\u3044\u306e\u3067\u300c\u307e\u305f\u4eca\u5ea6\u306b\u3057\u3088\u3046\ud83d\ude09\u300d\u3068\u8003\u3048\u3066\u3044\u305f\u6a5f\u80fd\u3092\u601d\u3044\u51fa\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u304c\u3001<\/p>\n<p><strong style=\"font-size: 35px;\">\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\uff08WebPush\uff09<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3068\u306f\u3001\u3042\u308b\u7279\u5b9a\u306e\u901a\u77e5\u304c\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u30e6\u30fc\u30b6\u30fc\u306b\u304a\u77e5\u3089\u305b\u3055\u308c\u308b\u901a\u77e5\u306e\u3053\u3068\u3067\u3001<code>WebPush<\/code>\u306f\u306a\u3093\u3068\u30d6\u30e9\u30a6\u30b6\u3067\u30b5\u30a4\u30c8\u3092\u958b\u3044\u3066\u3044\u306a\u304f\u3066\u3082\u901a\u77e5\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u5b9f\u306f\u3001\u6700\u8fd1\u306e\u30d6\u30e9\u30a6\u30b6\u306b\u306f\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u6a5f\u80fd\u304c\u5b9f\u88c5\u3055\u308c\u3066\u3044\u308b\u306e\u3092\u77e5\u3063\u3066\u3044\u308b\u3067\u3057\u3087\u3046\u304b\u3002\uff08\u30d6\u30e9\u30a6\u30b6\u306e\u30b5\u30dd\u30fc\u30c8\u72b6\u6cc1\u306f<a href=\"https:\/\/caniuse.com\/#feat=push-api\" target=\"_blank\" rel=\"noopener noreferrer\">Can I use<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\uff09<\/p>\n<p>\u305d\u3053\u3067\uff01<\/p>\n<p>\u4eca\u56de\u306f\u30d6\u30e9\u30a6\u30b6\u306b\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u9001\u308bWebPush\u3092\u6211\u3089\u304cLaravel\u3067\u5b9f\u88c5\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u306e\u304a\u5f79\u306b\u7acb\u3066\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\ud83d\ude0a\u2728<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2035 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/blurred_4.png\" alt=\"\" width=\"320\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/blurred_4.png 320w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/blurred_4-150x150.png 150w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/blurred_4-300x300.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/blurred_4-100x100.png 100w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/><\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Laravel 6.x\u3001Google Chrome 79<\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u4eca\u56de\u306f\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u4f7f\u3063\u3066\u3001<strong>\u300c\u30e6\u30fc\u30b6\u30fc\u306e\u7686\u3055\u3093\u3001\u65b0\u3057\u3044\u30a4\u30d9\u30f3\u30c8\u304c\u767b\u9332\u3055\u308c\u307e\u3057\u305f\u3088\uff01\u30af\u30ea\u30c3\u30af\u3057\u3066\u30a4\u30d9\u30f3\u30c8\u306e\u30da\u30fc\u30b8\u3092\u898b\u306b\u6765\u3066\u306d\ud83d\ude0a\u2728\u300d<\/strong>\u3068\u3044\u3046\u304a\u77e5\u3089\u305b\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u3084\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n<h1>\u524d\u63d0\u3068\u3057\u3066<\/h1>\n<p>\u4eca\u56de\u306e\u8a18\u4e8b\u306f\u3001<code>Laravel<\/code>\u306e\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u304c\u3059\u3067\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u524d\u63d0\u3068\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u3082\u3057\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u307e\u3060\u306e\u65b9\u306f\u4ee5\u4e0b\u3092\u53c2\u8003\u306b\u3057\u3066\u6e96\u5099\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li>Laravel 6.x \u4ee5\u4e0a\u3000\u30fb\u30fb\u30fb\u3000<a href=\"https:\/\/blog.capilano-fw.com\/?p=4576\">Laravel6.0\u3067\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u3092\u4f7f\u3046\u65b9\u6cd5<\/a><\/li>\n<li>\u305d\u308c\u672a\u6e80\u3000\u30fb\u30fb\u30fb\u3000<a href=\"https:\/\/blog.capilano-fw.com\/?p=289\">\u3010Laravel5.6\u3011\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u76f4\u5f8c\u306b\u3084\u308b\u3053\u3068\uff13\u70b9<\/a><\/li>\n<\/ul>\n<p>\u307e\u305f\u3001\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u306f\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u3042\u3063\u3066\u3082<code>HTTPS<\/code>\u3067\u306e\u63a5\u7d9a\u304c\u5fc5\u9808\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><strong>\u203b \u53b3\u5bc6\u306b\u306f\u81ea\u5df1\u8a3c\u660e\u66f8\u3067\u306e<code>HTTPS<\/code>\u3082\u4e0d\u53ef\u3067\u3059\u3002\u5bfe\u51e6\u6cd5\u306b\u3064\u3044\u3066\u306f<a href=\"#env_error\">\u63a5\u7d9a\u74b0\u5883\u306e\u30a8\u30e9\u30fc\u306b\u3064\u3044\u3066<\/a>\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/strong><\/p>\n<h1>\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h1>\n<p><code>WebPush<\/code>\u5c02\u7528\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u516c\u958b\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u5148\u306b<code>composer<\/code>\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre><strong>composer require laravel-notification-channels\/webpush<\/strong><\/pre>\n<h1>\u6e96\u5099\u3059\u308b<\/h1>\n<h2>DB\u306b\u30c6\u30fc\u30d6\u30eb\u3092\u3064\u304f\u308b<\/h2>\n<p>\u5148\u307b\u3069\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u30d1\u30c3\u30b1\u30fc\u30b8\u304b\u3089\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5074\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan vendor:publish --provider=\"NotificationChannels\\WebPush\\WebPushServiceProvider\" --tag=\"migrations\"<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001<code>database\/migrations\/****_**_**_******_create_push_subscriptions_table.php<\/code><\/p>\n<p>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066DB\u306b\u5c02\u7528\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>php artisan migrate<\/strong><\/pre>\n<p>\u5b9f\u884c\u304c\u5b8c\u4e86\u3059\u308b\u3068\u30c6\u30fc\u30d6\u30eb\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5405\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_1.png\" alt=\"\" width=\"350\" height=\"338\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_1.png 350w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_1-300x290.png 300w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/p>\n<h2>\u30c8\u30ec\u30a4\u30c8\u3092\u30e2\u30c7\u30eb\u306b\u8ffd\u52a0\u3059\u308b<\/h2>\n<p><code>WebPush<\/code>\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b<code>app\/User.php<\/code>\u3078<code>HasPushSubscriptions<\/code>\u3068\u3044\u3046\u540d\u524d\u306e\u30c8\u30ec\u30a4\u30c8\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App;\r\n\r\nuse Illuminate\\Contracts\\Auth\\MustVerifyEmail;\r\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\r\nuse Illuminate\\Notifications\\Notifiable;\r\n<strong>use NotificationChannels\\WebPush\\HasPushSubscriptions;<\/strong>\r\n\r\nclass User extends Authenticatable\r\n{\r\n    use Notifiable;\r\n    <strong>use HasPushSubscriptions;\r\n\r\n<\/strong>    \/\/ \u4ee5\u4e0b\u7701\u7565<\/pre>\n<h2>VAPID\u3092\u3064\u304f\u308b<\/h2>\n<p><code>WebPush<\/code>\u3092\u5b9f\u88c5\u3059\u308b\u305f\u3081\u306b\u5fc5\u8981\u306a\u30ad\u30fc\u3092\u3064\u304f\u308a\u307e\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan webpush:vapid<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u81ea\u52d5\u7684\u306b<code>.env<\/code>\u5185\u306b\u5fc5\u8981\u306a\u30ad\u30fc\u3092\u8ffd\u52a0\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<pre><strong>VAPID_PUBLIC_KEY=******************************\r\nAPID_PRIVATE_KEY=******************************<\/strong><\/pre>\n<h2>\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u306eNotification\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u3001<code>Laravel<\/code>\u304b\u3089<code>WebPush<\/code>\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u5c02\u7528\u306e<code>Notification<\/code>\u3092\u3064\u304f\u308a\u307e\u3057\u3087\u3046\u3002\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:notification EventAdded<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001<code>app\/Notifications\/EventAdded.php<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u3001\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>&lt;?php<\/strong>\r\n\r\n<strong>namespace App\\Notifications;<\/strong>\r\n\r\n<strong>use Illuminate\\Notifications\\Notification;<\/strong>\r\n<strong>use NotificationChannels\\WebPush\\WebPushChannel;<\/strong>\r\n<strong>use NotificationChannels\\WebPush\\WebPushMessage;<\/strong>\r\n\r\n<strong>class EventAdded extends Notification<\/strong>\r\n<strong>{<\/strong>\r\n<strong>    public function via($notifiable)<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        return [WebPushChannel::class];<\/strong>\r\n<strong>    }<\/strong>\r\n\r\n<strong>    public function toWebPush($notifiable, $notification)<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        return (new WebPushMessage)<\/strong>\r\n<strong>            -&gt;title('\u65b0\u30a4\u30d9\u30f3\u30c8')<\/strong>\r\n<strong>            -&gt;body('\u65b0\u3057\u3044\u30a4\u30d9\u30f3\u30c8\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\uff01')<\/strong>\r\n<strong>            -&gt;data([<\/strong>\r\n<strong>                'url' =&gt; url('\/test\/15')<\/strong>\r\n<strong>            ])<\/strong><strong>;<\/strong>\r\n<strong>    }<\/strong>\r\n<strong>}<\/strong><\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u306f\u3001\u5148\u307b\u3069\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u30d1\u30c3\u30b1\u30fc\u30b8\u306e<code>WebPushMessage<\/code>\u3092\u4f7f\u3063\u3066\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u4fe1\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u4eca\u56de\u306f\u30b7\u30f3\u30d7\u30eb\u306b4\u3064\u3060\u3051\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u305d\u306e\u4ed6\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306f<a href=\"https:\/\/developer.mozilla.org\/ja\/docs\/Web\/API\/notification\" target=\"_blank\" rel=\"noopener noreferrer\">\u3053\u3061\u3089\u306e\u30da\u30fc\u30b8<\/a>\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u307e\u305f\u3001<code>data()<\/code>\u5185\u306e<code>url<\/code>\u306f\u30c6\u30b9\u30c8\u306e<code>URL<\/code>\u3067\u3059\u3002<br \/>\n\u672c\u756a\u74b0\u5883\u3067\u5b9f\u88c5\u3059\u308b\u306b\u306f\u3001\u8a72\u5f53\u3059\u308b<code>URL<\/code>\u306b\u7f6e\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h1>\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u306e\u767b\u9332\u30da\u30fc\u30b8\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3053\u3053\u304b\u3089\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u8a31\u53ef\u3057\u3001\u305d\u306e\u30c7\u30fc\u30bf\u304c\u30b5\u30a4\u30c8\u5074\u306b\u4fdd\u5b58\u3055\u308c\u308b\u307e\u3067\u306e\u4f5c\u696d\u3092\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30eb\u30fc\u30c8\u3092\u3064\u304f\u308b<\/h2>\n<p>\u307e\u305a\u306f\u30eb\u30fc\u30c8\u3092\u3064\u304f\u308a\u307e\u3059\u3002<br \/>\n<code>routes\/web.php<\/code>\u3092\u958b\u3044\u3066\u4ee5\u4e0b\u306e\uff12\u884c\u3092\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>Route::get('web_push\/create', 'WebPushController@create');<\/strong>\r\n<strong>Route::post('web_push', 'WebPushController@store');<\/strong><\/pre>\n<h2>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308b<\/h2>\n<p>\u6b21\u306b\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308a\u307e\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:controller WebPushController<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001<code>app\/Http\/Controllers\/WebPushController.php<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u3001\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse Illuminate\\Http\\Request;\r\n\r\nclass WebPushController extends Controller\r\n{\r\n    <strong>public function __construct() {<\/strong>\r\n\r\n<strong>        $this-&gt;middleware('auth');  \/\/ \u8981\u30ed\u30b0\u30a4\u30f3<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>    public function create() {<\/strong>\r\n\r\n<strong>        return view('web_push.create');<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>    public function store(Request $request) {<\/strong>\r\n\r\n<strong>        $this-&gt;validate($request, [<\/strong>\r\n<strong>            'endpoint'    =&gt; 'required',<\/strong>\r\n<strong>            'keys.auth'   =&gt; 'required',<\/strong>\r\n<strong>            'keys.p256dh' =&gt; 'required'<\/strong>\r\n<strong>        ]);<\/strong>\r\n\r\n<strong>        $endpoint = $request-&gt;endpoint;<\/strong>\r\n<strong>        $token = $request-&gt;keys['auth'];<\/strong>\r\n<strong>        $key = $request-&gt;keys['p256dh'];<\/strong>\r\n<strong>        $user = $request-&gt;user();<\/strong>\r\n<strong>        $user-&gt;updatePushSubscription($endpoint, $key, $token);<\/strong>\r\n\r\n<strong>        return response()-&gt;json([<\/strong>\r\n<strong>            'success' =&gt; true<\/strong>\r\n<strong>        ], 200);<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u306a\u304a\u3001\u3053\u306e\u4e2d\u3067\u91cd\u8981\u306a\u306e\u306f<code>$this-&gt;middleware('auth');<\/code>\u306e\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p>\u610f\u5473\u3068\u3057\u3066\u306f\u300c\u3053\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u5834\u5408\u3001\u30ed\u30b0\u30a4\u30f3\u304c\u5fc5\u9808\u300d\u3068\u306a\u308a\u307e\u3059\u304c\u3001\u3053\u308c\u306f<code>store()<\/code>\u306e\u4e2d\u3067\u7279\u5b9a\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u305f\u3081\u3067\u3059\u3002<\/p>\n<h2>\u30d3\u30e5\u30fc\u3092\u3064\u304f\u308b<\/h2>\n<p>\u7d9a\u3044\u3066\u3001\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u767b\u9332\u3059\u308b\u30da\u30fc\u30b8\u306e\u30d3\u30e5\u30fc\uff08HTML+JavaScript\uff09\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><code>resources\/views\/web_push\/create.blade.php<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u3063\u3066\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre>&lt;html&gt;\r\n&lt;body&gt;\r\n    &lt;div id=\"app\"&gt;\r\n        &lt;div v-if=\"processing\"&gt;\u51e6\u7406\u4e2d...&lt;\/div&gt;\r\n        &lt;div v-else&gt;\r\n            <strong>&lt;button type=\"button\" @click=\"subscribe\" v-if=\"!isSubscribed\"&gt;\u30a4\u30d9\u30f3\u30c8\u306e\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u767b\u9332\u3059\u308b&lt;\/button&gt;<\/strong>\r\n<strong>            &lt;button type=\"button\" @click=\"unsubscribe\" v-else&gt;\u30a4\u30d9\u30f3\u30c8\u306e\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u89e3\u9664\u3059\u308b&lt;\/button&gt;<\/strong>\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n    &lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue@2.6.11\"&gt;&lt;\/script&gt;\r\n    &lt;script&gt;\r\n\r\n        new Vue({\r\n            el: '#app',\r\n            data: {\r\n                vapidPublicKey: '{{ config('webpush.vapid.public_key') }}',\r\n                registration: null,\r\n                isSubscribed: false,\r\n                processing: false,\r\n                csrfToken: '{{ csrf_token() }}'\r\n            },\r\n            methods: {\r\n                <strong>subscribe() {   \/\/ \u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u8a31\u53ef\u3059\u308b<\/strong>\r\n\r\n<strong>                    this.processing = true;<\/strong>\r\n<strong>                    const applicationServerKey = this.base64toUint8(this.vapidPublicKey);<\/strong>\r\n<strong>                    const options = {<\/strong>\r\n<strong>                        userVisibleOnly: true,<\/strong>\r\n<strong>                        applicationServerKey: applicationServerKey<\/strong>\r\n<strong>                    };<\/strong>\r\n<strong>                    this.registration.pushManager.subscribe(options)<\/strong>\r\n<strong>                        .then(subscription =&gt; {<\/strong>\r\n\r\n<strong>                            \/\/ Laravel\u5074\u3078\u30c7\u30fc\u30bf\u3092\u9001\u4fe1<\/strong>\r\n<strong>                            fetch('\/web_push', {<\/strong>\r\n<strong>                                method: 'POST',<\/strong>\r\n<strong>                                body: JSON.stringify(subscription),<\/strong>\r\n<strong>                                headers: {<\/strong>\r\n<strong>                                    'Accept': 'application\/json',<\/strong>\r\n<strong>                                    'Content-Type': 'application\/json',<\/strong>\r\n<strong>                                    'X-CSRF-Token': this.csrfToken<\/strong>\r\n<strong>                                }<\/strong>\r\n<strong>                            })<\/strong>\r\n<strong>                            .then(response =&gt; {<\/strong>\r\n\r\n<strong>                                this.isSubscribed = true;<\/strong>\r\n<strong>                                alert('\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u304c\u767b\u9332\u3055\u308c\u307e\u3057\u305f');<\/strong>\r\n\r\n<strong>                            })<\/strong>\r\n<strong>                            .catch(error =&gt; {<\/strong>\r\n\r\n<strong>                                console.log(error);<\/strong>\r\n\r\n<strong>                            });<\/strong>\r\n\r\n<strong>                        })<\/strong>\r\n<strong>                        .finally(() =&gt; {<\/strong>\r\n\r\n<strong>                            this.processing = false;<\/strong>\r\n\r\n<strong>                        });<\/strong>\r\n\r\n<strong>                },<\/strong>\r\n<strong>                unsubscribe() { \/\/ \u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u89e3\u9664\u3059\u308b<\/strong>\r\n\r\n<strong>                    this.processing = true;<\/strong>\r\n<strong>                    this.registration.pushManager.getSubscription()<\/strong>\r\n<strong>                        .then(subscription =&gt; {<\/strong>\r\n<strong>                            subscription.unsubscribe()<\/strong>\r\n<strong>                                .then(result =&gt; {<\/strong>\r\n\r\n<strong>                                    if(result) {<\/strong>\r\n\r\n<strong>                                        this.isSubscribed = false;<\/strong>\r\n<strong>                                        alert('\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u304c\u89e3\u9664\u3055\u308c\u307e\u3057\u305f');<\/strong>\r\n\r\n<strong>                                    }<\/strong>\r\n\r\n<strong>                                });<\/strong>\r\n<strong>                        })<\/strong>\r\n<strong>                        .finally(() =&gt; {<\/strong>\r\n\r\n<strong>                            this.processing = false;<\/strong>\r\n\r\n<strong>                        });<\/strong>\r\n\r\n<strong>                },<\/strong>\r\n                base64toUint8(str) {\r\n\r\n                    str += '='.repeat((4 - str.length % 4) % 4);\r\n                    const base64 = str\r\n                        .replace(new RegExp('\\-', 'g'), '+')\r\n                        .replace(new RegExp('_', 'g'), '\/');\r\n\r\n                    const binary = window.atob(base64);\r\n                    const binaryLength = binary.length;\r\n                    let uint8Array = new Uint8Array(binaryLength);\r\n\r\n                    for(let i = 0; i &lt; binaryLength; i++) {\r\n\r\n                        uint8Array[i] = binary.charCodeAt(i);\r\n\r\n                    }\r\n\r\n                    return uint8Array.buffer;\r\n                }\r\n            },\r\n            <strong>mounted() {<\/strong>\r\n\r\n<strong>                if('serviceWorker' in navigator &amp;&amp; 'PushManager' in window) {<\/strong>\r\n\r\n<strong>                    \/\/ Service Worker\u3092\u30d6\u30e9\u30a6\u30b6\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/strong>\r\n<strong>                    navigator.serviceWorker.register('\/sw.js')<\/strong>\r\n<strong>                        .then(registration =&gt; {<\/strong>\r\n\r\n<strong>                            console.log('Service Worker \u304c\u767b\u9332\u3055\u308c\u307e\u3057\u305f\u3002');<\/strong>\r\n<strong>                            this.registration = registration;<\/strong>\r\n<strong>                            this.registration.pushManager.getSubscription()<\/strong>\r\n<strong>                                .then(subscription =&gt; {<\/strong>\r\n\r\n<strong>                                    this.isSubscribed = !(subscription === null);<\/strong>\r\n\r\n<strong>                                });<\/strong>\r\n\r\n<strong>                        });<\/strong>\r\n\r\n<strong>                } else {<\/strong>\r\n\r\n<strong>                    console.log('\u3053\u306e\u30d6\u30e9\u30a6\u30b6\u306f\u3001\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u307e\u305b\u3093\u3002');<\/strong>\r\n\r\n<strong>                }<\/strong>\r\n\r\n<strong>            }<\/strong>\r\n        });\r\n\r\n    &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u203b \u30c6\u30b9\u30c8\u306e\u305f\u3081\u3001\u30a8\u30e9\u30fc\u51e6\u7406\u306a\u3069\u306f\u7701\u7565\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u6c17\u3092\u3064\u3051\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3053\u306e\u4e2d\u3067\u91cd\u8981\u306a\u306e\u306f\u4ee5\u4e0b\u306e\uff13\u3064\u306e\u90e8\u5206\u3067\u3059\u3002<\/p>\n<ul>\n<li>Service Worker\u3092\u767b\u9332\u3059\u308b<\/li>\n<li>\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u8a31\u53ef\u3059\u308b<\/li>\n<li>\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u89e3\u9664\u3059\u308b<\/li>\n<\/ul>\n<p>\u5c11\u3057\u30b3\u30fc\u30c9\u304c\u9577\u3044\u306e\u3067\u305d\u308c\u305e\u308c\u8aac\u660e\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h3>Service Worker\u3092\u767b\u9332\u3059\u308b<\/h3>\n<p>\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u5b9f\u88c5\u3059\u308b\u306b\u306f\u3001\u307e\u305a<code>Service Worker<\/code>\u3068\u547c\u3070\u308c\u308b<code>JavaScript<\/code>\u3092\u30d6\u30e9\u30a6\u30b6\u306b\u767b\u9332\uff08\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff09\u3057\u3066\u304a\u3044\u3066\u3001\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3055\u308c\u305f\u308a\u3001\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3068\u304d\u306b\u3053\u306e\u30b3\u30fc\u30c9\u304c\u5b9f\u884c\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\uff08<code>Service Worker<\/code>\u306e\u672c\u4f53\u30b3\u30fc\u30c9\u306f\u6b21\u306e\u9805\u76ee\u3067\u4f5c\u6210\u3057\u307e\u3059\uff09<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u305f\u6642\u70b9\u3067\u547c\u3070\u308c\u308b<code>mounted()<\/code>\u306e\u4e2d\u3067\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u8a31\u53ef\u3059\u308b<\/h3>\n<p><strong>\u300c\u30a4\u30d9\u30f3\u30c8\u306e\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u767b\u9332\u3059\u308b\u300d<\/strong>\u30dc\u30bf\u30f3\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3068\u304d\u306b\u547c\u3070\u308c\u308b<code>subscribe()<\/code>\u30e1\u30bd\u30c3\u30c9\u5185\u3067\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u304c\u767b\u9332\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u4e2d\u3067\u306f\u3001<code>pushManager.subscribe()<\/code>\u3092\u5b9f\u884c\uff06\u8a31\u53ef\u3092\u5f97\u308b\u3053\u3068\u3067\u3001\u767b\u9332\u60c5\u5831\u3092\u53d6\u5f97\u3057\u3001\u3053\u308c\u3092<code>Laravel<\/code>\u5074\u306b \u9001\u4fe1\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\u9001\u4fe1\u5148\u306f\u3001<code>WebPushController<\/code>\u306e<code>store()<\/code>\u3067\u3059\u3002<\/p>\n<h3>\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u89e3\u9664\u3059\u308b<\/h3>\n<p>\u3059\u3067\u306b\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u304c\u8a31\u53ef\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u306b\u8868\u793a\u3055\u308c\u308b<strong>\u300c\u30a4\u30d9\u30f3\u30c8\u306e\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u89e3\u9664\u3059\u308b\u300d<\/strong>\u30dc\u30bf\u30f3\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3068\u304d\u306b\u5b9f\u884c\u3055\u308c\u308b\u306e\u304c\u3001<code>unsubscribe()<\/code>\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<\/p>\n<h2>Service Worker\u672c\u4f53\u3092\u3064\u304f\u308b<\/h2>\n<p>\u5148\u307b\u3069\u306e\u9805\u76ee\u3067<code>Service Worker<\/code>\u3092\u767b\u9332\u3059\u308b\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u307e\u3060<code>Service Worker<\/code>\u672c\u4f53\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u305b\u3093\u306e\u3067\u3001\u3053\u3053\u3067\u3064\u304f\u308a\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><code>public\/sw.js<\/code>\u306b\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3001\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>self.addEventListener('push', e =&gt; {    \/\/ \u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3055\u308c\u305f\u6642<\/strong>\r\n\r\n<strong>    const json = e.data.json();<\/strong>\r\n<strong>    const title = json.title;<\/strong>\r\n<strong>    const options = {<\/strong>\r\n<strong>        body: json.body,<\/strong>\r\n<strong>        data: {<\/strong>\r\n<strong>            url: json.data.url,<\/strong>\r\n<strong>        }<\/strong>\r\n<strong>    };<\/strong>\r\n<strong>    e.waitUntil(<\/strong>\r\n<strong>        self.registration.showNotification(title, options)<\/strong>\r\n<strong>    );<\/strong>\r\n\r\n<strong>});<\/strong>\r\n<strong>self.addEventListener('notificationclick', e =&gt; {   \/\/ \u901a\u77e5\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u6642<\/strong>\r\n\r\n<strong>    const data = e.notification.data;<\/strong>\r\n<strong>    e.waitUntil(<\/strong>\r\n<strong>        clients.openWindow(data.url)<\/strong>\r\n<strong>    );<\/strong>\r\n\r\n<strong>});<\/strong><\/pre>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>\u203b \u6ce8\u610f\uff1a\u3082\u3057\u5b9f\u884c\u3057\u3066\u30a8\u30e9\u30fc\u304c\u8868\u793a\u3055\u308c\u305f\u5834\u5408\u306f\u3001<a href=\"#env_error\">\u63a5\u7d9a\u74b0\u5883\u306e\u30a8\u30e9\u30fc\u306b\u3064\u3044\u3066<\/a>\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\uff08\u3068\u3044\u3046\u304b\u3001\u304a\u305d\u3089\u304f\u30a8\u30e9\u30fc\u8868\u793a\u3055\u308c\u308b\u3068\u601d\u3044\u307e\u3059\uff09<\/strong><\/p>\n<p>\u307e\u305a<code>https:\/\/*****\/web_push\/create<\/code>\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u8868\u793a\u306b\u306a\u308a\u307e\u3059\u306e\u3067\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u306b\u8a31\u53ef\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5426\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_7.png\" alt=\"\" width=\"479\" height=\"77\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_7.png 479w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_7-300x48.png 300w\" sizes=\"auto, (max-width: 479px) 100vw, 479px\" \/><\/p>\n<p>\u8a31\u53ef\u304c\u5b8c\u4e86\u3059\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306a\u30a2\u30e9\u30fc\u30c8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5427\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_8.png\" alt=\"\" width=\"446\" height=\"133\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_8.png 446w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_8-300x89.png 300w\" sizes=\"auto, (max-width: 446px) 100vw, 446px\" \/><\/p>\n<p>\u3067\u306f\u3001\u3053\u306e\u72b6\u614b\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092<code>routes\/web.php<\/code>\u306b\u8ffd\u52a0\u3057\u3066\u3001<code>https:\/\/******\/web_push_test<\/code>\u306b\u30a2\u30af\u30bb\u30b9\u3092\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>\/\/ \u5168\u30e6\u30fc\u30b6\u30fc\u306b\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u8a66\u307f\u308b\r\n<strong>Route::get('web_push_test', function(){<\/strong>\r\n\r\n<strong>    $users = \\App\\User::all();<\/strong>\r\n<strong>    \\Notification::send($users, new \\App\\Notifications\\EventAdded());<\/strong>\r\n\r\n<strong>});<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306a\u901a\u77e5\u304c\u6765\u307e\u3057\u305f\uff01\uff08<code>OS<\/code>\u304c<code>Linux<\/code>\u306a\u306e\u3067\u3001<code>Windows<\/code>\u3067\u306f\u307e\u305f\u9055\u3063\u305f\u30c7\u30b6\u30a4\u30f3\u3060\u3068\u601d\u3044\u307e\u3059\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5428\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_9.png\" alt=\"\" width=\"512\" height=\"78\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_9.png 512w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_9-300x46.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n<p>\u3046\u307e\u304f\u3044\u304d\u307e\u3057\u305f\ud83d\ude0a\u2728<\/p>\n<h1>\u30a8\u30e9\u30fc\u304c\u8868\u793a\u3055\u308c\u305f\u3089<\/h1>\n<h2 id=\"env_error\">\u63a5\u7d9a\u74b0\u5883\u306e\u30a8\u30e9\u30fc\u306b\u3064\u3044\u3066<\/h2>\n<p>\u304a\u305d\u3089\u304f\u3067\u3059\u304c\u3001<code>JavaScript<\/code>\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u3001\u30d6\u30e9\u30a6\u30b6\u306e<code>DevTools<\/code>\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u304c\u8868\u793a\u3055\u308c\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<pre>DOMException: Failed to register a ServiceWorker for scope ('https:\/\/******\/') with script ('https:\/\/******\/sw.js'): \r\nAn SSL certificate error occurred when fetching the script.<\/pre>\n<p>\u306a\u305c\u3053\u306e\u8868\u793a\u304c\u51fa\u308b\u304b\u3068\u3044\u3046\u3068\u3001<code>ServiceWorker<\/code>\u306f\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u4e0a\u306e\u7406\u7531\u304b\u3089\u6b21\u306e\u6761\u4ef6\u304c\u5fc5\u9808\u306b\u306a\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<ol>\n<li>HTTPS\u3067\u63a5\u7d9a\u3057\u3066\u3044\u308b<\/li>\n<li><strong>\u3057\u304b\u3082\u8a3c\u660e\u66f8\u306f\u81ea\u5206\u3067\u4f5c\u3063\u305f\u8a3c\u660e\u66f8\u3058\u3083\u30c0\u30e1\uff01\uff01<\/strong>\ud83d\ude2b<\/li>\n<\/ol>\n<p>\u79c1\u306e\u74b0\u5883\u3067\u3082\u81ea\u5df1\u8a3c\u660e\u66f8\uff08\u3044\u308f\u3086\u308b\u30aa\u30ec\u30aa\u30ec\u8a3c\u660e\uff09\u3067<code>HTTPS<\/code>\u63a5\u7d9a\u3092\u3057\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u30d6\u30e9\u30a6\u30b6\u5074\u306b<strong>\u300c\u3053\u308c\u3058\u3083\u5371\u967a\u3060\u304b\u3089\u30c0\u30e1\u3088\uff01\u300d<\/strong>\u3068\u30a8\u30e9\u30fc\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3067\u306f\u3001\u3069\u3046\u3059\u308c\u3070\u3044\u3044\u304b\u3068\u3044\u3046\u3068\u3001\u4f8b\u3048\u3070<code>Google Chrome<\/code>\u306e\u5834\u5408\u306f\u8d77\u52d5\u306e\u4ed5\u65b9\u3067\u3053\u306e\u8a3c\u660e\u66f8\u306e\u30c1\u30a7\u30c3\u30af\u3092\u7121\u8996\u3059\u308b\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\uff08\u3082\u3061\u308d\u3093\u666e\u901a\u306b\u8d77\u52d5\u3057\u305f\u5834\u5408\u306f\u3001\u3070\u3063\u3061\u308a\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5b8c\u5099\u3067\u3059\uff09<\/p>\n<p>\u3084\u308a\u304b\u305f\u306f\u3001<code>Google Chrome<\/code>\u304c\u8d77\u52d5\u3059\u308b\u30d1\u30b9\u306b\u30aa\u30d7\u30b7\u30e7\u30f3\u5024\u3092\u3064\u3051\u3066\u30b3\u30de\u30f3\u30c9\u304b\u3089\u8d77\u52d5\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<pre><strong>google-chrome --ignore-certificate-errors --unsafely-treat-insecure-origin-as-secure=https:\/\/\uff08\u30ed\u30fc\u30ab\u30eb\u306e\u30c9\u30e1\u30a4\u30f3\uff09 --allow-insecure-localhost --user-data-dir=\/tmp\/foo<\/strong><\/pre>\n<p>\u203b \u3061\u306a\u307f\u306b<code>--user-data-dir<\/code>\u306f\u304d\u3061\u3093\u3068\u5b58\u5728\u3059\u308b\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u306e\u30d5\u30a9\u30eb\u30c0\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u305d\u3046\u3067\u306a\u3044\u3068\u3001\u30a8\u30e9\u30fc\u3067\u8d77\u52d5\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<h2>\u9593\u9055\u3063\u3066\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u62d2\u5426\u3057\u3066\u3057\u307e\u3063\u305f\u3089<\/h2>\n<p>\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u306e\u8a31\u53ef\u3092\u6c42\u3081\u3089\u308c\u305f\u3068\u304d\u306b\u9593\u9055\u3063\u3066\u62d2\u5426\u3057\u305f\u308a\u3001\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u6d88\u3057\u3066\u3057\u307e\u3046\u3068\u3001\u305d\u308c\u4ee5\u964d\u30d6\u30ed\u30c3\u30af\u3055\u308c\u3066\u3057\u307e\u3044\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u304c\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>Notifications permission has been blocked as the user has dismissed the permission prompt several times. \r\nThis can be reset in Page Info which can be accessed by clicking the lock icon next to the URL.<\/pre>\n<p>\u305d\u3093\u306a\u5834\u5408\u306f\u3001\uff08<code>Google Chrome<\/code>\u306e\u5834\u5408\u3060\u3068\uff09\u30d6\u30e9\u30a6\u30b6\u306e\u30d5\u30a1\u30d3\u30b3\u30f3\u304c\u8868\u793a\u3055\u308c\u308b\u90e8\u5206\u3092\u30af\u30ea\u30c3\u30af\u3057\u3001\u901a\u77e5\u306e\u90e8\u5206\u3092<strong>\u300c\u78ba\u8a8d\uff08\u30c7\u30d5\u30a9\u30eb\u30c8\uff09\u300d<\/strong>\u3078\u5909\u66f4\u3057\u3066\u3001\u30da\u30fc\u30b8\u3092\u30ea\u30ed\u30fc\u30c9\u3057\u3066\u304f\u3060\u3055\u3044<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5413\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_6.png\" alt=\"\" width=\"488\" height=\"477\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_6.png 488w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_6-300x293.png 300w\" sizes=\"auto, (max-width: 488px) 100vw, 488px\" \/><\/p>\n<h1>\u958b\u767a\u6642\u306e\u4fbf\u5229\u6a5f\u80fd\u3092\u4f7f\u3046<\/h1>\n<h2 id=\"additional_1\">\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u7121\u8996\u3057\u3066\u6700\u65b0\u30b3\u30fc\u30c9\u304c\u53cd\u6620\u3055\u308c\u308b\u3088\u3046\u306b\u3059\u308b<\/h2>\n<p><code>Service Worker<\/code>\u306f\u3001\u30d6\u30e9\u30a6\u30b6\u306b\u767b\u9332\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308b\u306e\u3067\u3059\u304c\u3001\u958b\u767a\u4e2d\u306b\u554f\u984c\u306b\u306a\u3063\u3066\u304f\u308b\u3053\u3068\u306e\u3072\u3068\u3064\u3067<strong>\u300c\u6700\u65b0\u306e\u30b3\u30fc\u30c9\u304c\u53cd\u6620\u3055\u308c\u306a\u3044\u300d<\/strong>\u3068\u3044\u3046\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3092\u89e3\u6c7a\u3059\u308b\u305f\u3081\u306b\u306f\u3001<code>Google Chrome<\/code>\u306e<code>DevTools<\/code>\u3092\u958b\u3044\u3066\uff08\u53f3\u30af\u30ea\u30c3\u30af &gt; \u691c\u8a3c\uff09\u3001Application\u30bf\u30d6 &gt; Service Workers \u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30ea\u30ed\u30fc\u30c9\u3059\u308b\u5ea6\u306b\u6700\u65b0\u306e\u3082\u306e\u306b\u3059\u308b\u8a2d\u5b9a<strong>\u300cUpdate on reload\u300d<\/strong>\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u3053\u3053\u306b\u30c1\u30a7\u30c3\u30af\u3092\u3044\u308c\u3066\u304a\u304f\u3068\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5407\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_3.png\" alt=\"\" width=\"607\" height=\"97\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_3.png 607w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_3-300x48.png 300w\" sizes=\"auto, (max-width: 607px) 100vw, 607px\" \/><\/p>\n<p>\u3053\u308c\u3067\u3001\u30d6\u30e9\u30a6\u30b6\u304c\u30ea\u30ed\u30fc\u30c9\u3055\u308c\u305f\u3089<code>Service Worker<\/code>\u3082\u81ea\u52d5\u7684\u306b\u6700\u65b0\u306e\u3082\u306e\u306b\u66f4\u65b0\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u30c6\u30b9\u30c8\u306e\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u3059\u308b<\/h2>\n<p>\u3053\u308c\u3082<code>Chrome<\/code>\u306e<code>DevTools<\/code>\u306e\u6a5f\u80fd\u3067\u3059\u304c\u3001\u64ec\u4f3c\u7684\u306b\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3055\u308c\u305f\u3088\u3046\u306b\u30c6\u30b9\u30c8\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"#additional_1\">\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u7121\u8996\u3057\u3066\u6700\u65b0\u30b3\u30fc\u30c9\u304c\u53cd\u6620\u3055\u308c\u308b\u3088\u3046\u306b\u3059\u308b<\/a> \u3067\u8868\u793a\u3057\u305fDevTools\u306e\u3059\u3050\u4e0b\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u90e8\u5206\u304c\u3042\u308b\u306e\u3067\u3001\u8a72\u5f53\u3059\u308b<code>Service Worker<\/code>\u3092\u63a2\u3057\u3066<code>Push<\/code>\u3068\u66f8\u304b\u308c\u305f\u9805\u76ee\u3092\u597d\u304d\u306a\u30c6\u30ad\u30b9\u30c8\u306b\u5909\u66f4\u3057<strong>\u300cPush\u300d<\/strong>\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3060\u3051\u3067OK\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5409\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_5.png\" alt=\"\" width=\"729\" height=\"253\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_5.png 729w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/12\/web_push_5-300x104.png 300w\" sizes=\"auto, (max-width: 729px) 100vw, 729px\" \/><\/p>\n<h1>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b<\/h1>\n<p>\u4eca\u56de\u5b9f\u969b\u306b\u958b\u767a\u3057\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f\u3092\u4ee5\u4e0b\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u203b \u305f\u3060\u3057\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3084<code>VAPID<\/code>\u306e\u4f5c\u6210\u306a\u3069\u306f\u3054\u81ea\u8eab\u3067\u884c\u3063\u3066\u3044\u305f\u3060\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"\" href=\"https:\/\/blog.capilano-fw.com?download=5421&amp;tmstv=1777532240\" rel=\"nofollow\" id=\"download-link-5421\" data-redirect=\"false\" >\n\tLaravel\u3067\u30d6\u30e9\u30a6\u30b6\u306b\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3059\u308b<\/a>\n\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f<code>Laravel<\/code>\u3092\u4f7f\u3063\u3066\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u9001\u308b\u65b9\u6cd5\u3092\u304a\u5c4a\u3051\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u306e\u69cb\u9020\u4e0a\u3001\u3044\u304f\u3064\u3082\u958b\u767a\u3057\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\u90e8\u5206\u304c\u3042\u308a\u307e\u3059\u304c\u3001<code>Laravel<\/code>\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u5c11\u3057\u306f\u697d\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u81ea\u4f53\u306b\u3064\u3044\u3066\u306e\u79c1\u306e\u96d1\u611f\u3067\u3059\u304c\u3001\u30b9\u30de\u30db\u30a2\u30d7\u30ea\u306e\u3088\u3046\u306b\u901a\u77e5\u3092\u9001\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u306f\u3061\u3087\u3063\u3068\u3057\u305f\u9769\u547d\u7684\u306a\u30a4\u30e1\u30fc\u30b8\u304c\u3042\u308b\u53cd\u9762\u3001\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3092\u4e00\u5ea6\u3067\u3082\u62d2\u5426\u3057\u3066\u3057\u307e\u3046\u3068\u3001\u305d\u308c\u3092\u89e3\u9664\u3059\u308b\u306e\u306b\u3061\u3087\u3063\u3068\u3057\u305f\u624b\u9593\u304c\u3042\u3063\u305f\u308a\u3059\u308b\u306e\u3067\u3001\u305d\u306e\u8fba\u304c\u5c11\u3057\u300c\u3046\u30fc\u3093\ud83d\ude05\u300d\u306a\u3068\u3053\u308d\u3060\u3063\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u500b\u4eba\u7684\u306b\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u306f\u300c\u3044\u3084\u3001\u305d\u3093\u306a\u3053\u3068\u307e\u3067\u901a\u77e5\u3057\u306a\u304f\u3066\u3044\u3044\u3088\ud83d\ude2b\u300d\u3068\u3044\u3046\u5185\u5bb9\u307e\u3067\u9001\u4fe1\u3057\u3066\u304f\u308b\u3053\u3068\u3082\u591a\u3044\u305f\u3081\u3001\u767a\u4fe1\u8005\u5074\u306e\u30e2\u30e9\u30eb\u304c\u4f4e\u3044\u3068\u3001\u3053\u306e\u6a5f\u80fd\u81ea\u4f53\u306e\u5370\u8c61\u304c\u60aa\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u3001\u30e6\u30fc\u30b6\u30fc\u304b\u3089\u656c\u9060\u3055\u308c\u3066\u3057\u307e\u3046\u3053\u3068\u3082\u3042\u308b\u3093\u3058\u3083\u306a\u3044\u304b\u3068\u3082\u611f\u3058\u307e\u3057\u305f\u3002<\/p>\n<p>\u3068\u306f\u3044\u3048\u3001\u3046\u307e\u304f\u4f7f\u3048\u3070\u52b9\u679c\u7684\u306a\u96c6\u5ba2\u306b\u3082\u3064\u306a\u3052\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u305c\u3072\u7686\u3055\u3093\u306e\u30b5\u30a4\u30c8\u3067\u3082\u6d3b\u7528\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-519 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/05\/21.png\" alt=\"\" width=\"192\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/05\/21.png 192w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/05\/21-180x300.png 180w\" sizes=\"auto, (max-width: 192px) 100vw, 192px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u9593\u306e\u30b3\u30d4\u30da\u3067OK\uff01Laravel\u304b\u3089wordpress\u306b\u6295\u7a3f\u3059\u308b\u6a5f\u80fd\u3068\u3044\u3046\u8a18\u4e8b\u3067\u306fLaravel\u306b\u72ec\u81ea\u306eNotification\u3092\u4f5c\u3063\u3066wordp &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=5404\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u52b9\u679c\u7684\uff01Laravel\u3067\u30d6\u30e9\u30a6\u30b6\u306b\u30d7\u30c3\u30b7\u30e5\u901a\u77e5\u3059\u308b\u6a5f\u80fd&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":5430,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[199,198],"class_list":["post-5404","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","tag-webpush","tag-198"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/5404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5404"}],"version-history":[{"count":12,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/5404\/revisions"}],"predecessor-version":[{"id":5429,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/5404\/revisions\/5429"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/5430"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}