walther PRO
Joined 3/10/2023
walther PRO said about 1 year ago on Push Notifications from Scratch :
hmm - when I introduce the vapid_public_key like in the shared example - I get this error in my Chrome ( Version 111.0.5563.64 (Officiel version) (arm64)) DevTools

Failed to execute 'subscribe' on 'PushManager': The provided applicationServerKey is not encoded as base64url without padding.

Comparing the key from the credentials with the one assigned to vapidPublicKey I find them to be matching 100%

Perhaps you might have a peek at https://blog.atulr.com/web-notifications/ - there's a function labeled 
urlB64ToUint8Array
which AFAICS is the magic pill 

walther PRO said about 1 year ago on Push Notifications from Scratch :
hmm - my steps were:

1 bundle add web-push
2 rails c vapid_key = ....
3 EDITOR=code --wait rails credentials:edit (c/p-ing the keys from the rails console)
4 add <head> meta
5 update the service_worker.js to getAttribute("content")

(and I don't believe my Chrome being perhaps 1-2 patch releases behind master is the deal-breaker)

walther PRO said about 1 year ago on Push Notifications from Scratch :
shouldn't conflict but I'm on 

√ src % rails -v
Rails 7.0.4
√ src % ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]

And my app head looks like

  <head>    
     <title>App</title>    
     <link rel="manifest" href="/manifest.json">    
     <meta name="theme-color" content="#8e2731">    
     <meta name="viewport" content="width=device-width,initial-scale=1">    
     <%= csrf_meta_tags %>    
     <%= csp_meta_tag %>    
     <%= tag :meta, name: :vapid_public_key, content: Rails.application.credentials.vapid.public_key %>    
     <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>    
     <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>  
  </head>







walther PRO said about 1 year ago on Push Notifications from Scratch :
on a slightly different note - yet very much focused with this PushNotification thing - I'm now seeing this in my log (and I'd hate to deploy this knowing that 1-200 users will soon start generating double GET's almost every second?!?
Started GET "/manifest.json" for 127.0.0.1 at 2023-03-30 20:36:37 +0200
Processing by ServiceWorkers::ManifestsController#index as JSON
  Rendering service_workers/manifests/index.json.erb
  Rendered service_workers/manifests/index.json.erb (Duration: 0.0ms | Allocations: 7)
Completed 200 OK in 4ms (Views: 0.4ms | ActiveRecord: 0.9ms | Allocations: 2283)


Started GET "/manifest.json" for 127.0.0.1 at 2023-03-30 20:36:37 +0200
Processing by ServiceWorkers::ManifestsController#index as JSON
  Rendering service_workers/manifests/index.json.erb
  Rendered service_workers/manifests/index.json.erb (Duration: 0.0ms | Allocations: 7)
Completed 200 OK in 4ms (Views: 0.3ms | ActiveRecord: 1.4ms | Allocations: 2283)


Started GET "/manifest.json" for 127.0.0.1 at 2023-03-30 20:36:38 +0200
Processing by ServiceWorkers::ManifestsController#index as JSON
  Rendering service_workers/manifests/index.json.erb
  Rendered service_workers/manifests/index.json.erb (Duration: 0.0ms | Allocations: 7)
Completed 200 OK in 4ms (Views: 0.4ms | ActiveRecord: 1.3ms | Allocations: 2283)


Started GET "/manifest.json" for 127.0.0.1 at 2023-03-30 20:36:38 +0200
Processing by ServiceWorkers::ManifestsController#index as JSON
  Rendering service_workers/manifests/index.json.erb
  Rendered service_workers/manifests/index.json.erb (Duration: 0.0ms | Allocations: 7)
Completed 200 OK in 3ms (Views: 0.3ms | ActiveRecord: 0.8ms | Allocations: 2283)


Started GET "/manifest.json" for 127.0.0.1 at 2023-03-30 20:36:50 +0200
Processing by ServiceWorkers::ManifestsController#index as JSON
  Rendering service_workers/manifests/index.json.erb
  Rendered service_workers/manifests/index.json.erb (Duration: 0.0ms | Allocations: 7)
Completed 200 OK in 5ms (Views: 0.5ms | ActiveRecord: 2.1ms | Allocations: 2283)


Started GET "/manifest.json" for 127.0.0.1 at 2023-03-30 20:36:50 +0200
Processing by ServiceWorkers::ManifestsController#index as JSON
  Rendering service_workers/manifests/index.json.erb
  Rendered service_workers/manifests/index.json.erb (Duration: 0.0ms | Allocations: 7)
Completed 200 OK in 3ms (Views: 0.2ms | ActiveRecord: 1.1ms | Allocations: 2283)


Started GET "/manifest.json" for 127.0.0.1 at 2023-03-30 20:36:51 +0200
Processing by ServiceWorkers::ManifestsController#index as JSON
  Rendering service_workers/manifests/index.json.erb
  Rendered service_workers/manifests/index.json.erb (Duration: 0.0ms | Allocations: 7)
Completed 200 OK in 4ms (Views: 0.4ms | ActiveRecord: 0.9ms | Allocations: 2283)


Started GET "/manifest.json" for 127.0.0.1 at 2023-03-30 20:36:51 +0200
Processing by ServiceWorkers::ManifestsController#index as JSON
  Rendering service_workers/manifests/index.json.erb
  Rendered service_workers/manifests/index.json.erb (Duration: 0.0ms | Allocations: 7)
Completed 200 OK in 3ms (Views: 0.3ms | ActiveRecord: 1.1ms | Allocations: 2283)