0

I`m使用してRailsとhttps://github.com/zaru/webpush宝石とは、このガイド私はServiceWorkerを登録し、サブスクリプションを取得するために管理し https://rossta.net/blog/web-push-notifications-from-rails.htmlクローム通知 - 400のUnauthorizedRegistration

に応じたものを設定しています。私が設定され、Googleのコンソール上でアカウントをアクティブ化した

message = { 
    title: "Title", 
    body: "This is a test notification", 
    icon: "images/my-128.png" 
} 

Webpush.payload_send(
    endpoint: current_user.gcm_endpoint, 
    message: JSON.generate(message), 
    p256dh: current_user.gcm_p256dh, 
    auth: current_user.gcm_auth, 
    ttl: 600, 
    api_key: "<MY API KEY>" 
) 

:私は

endpoint = params[:subscription][:endpoint] 
p256dh = params[:subscription][:keys][:p256dh] 
auth = params[:subscription][:keys][:auth] 

current_user.gcm_endpoint = endpoint 
current_user.gcm_p256dh = p256dh 
current_user.gcm_auth = auth 

後、私はこのようなメッセージを送信するコントローラでこのようにそれを保存します。 GCM APIを有効にして、正しいキーを追加しました。しかし、私が何をしても、私はこの400のエラーコードを受け取ります。 Googleのコンソールには統計情報がありません。APIコールを呼び出していないかのようです。

+0

[this](https://support.google.com/cloud/answer/6310037?hl=ja)をご覧ください。 –

答えて

0

問題はキー自体にありました。別のFirebaseコントロールパネルを使ってそれを生成する必要があります。 Hereそのキーで私のコードはうまく動作します。

関連する問題