2

こんにちは私はポリマー製のPWAからウェブプッシュ通知を送信したいのですが、ファイアベースを「バックエンド」として使用したいのですが、グーグルでは、私はそれを行うための良い例を見つけることができませんあなたはそれらのtecnologiesを使用して完全な例について知っていますか?ウェブベースのファイヤーベースとファイヤーベース機能を使用したポリマーと火災基地

ありがとうございます。あなたのfirebase関数にウェブプッシュをインストールする必要があります

答えて

1

npm install web-push --save

次に、ここでは、ライブラリを初期化し、通知を送信する方法です。

const webpush = require('web-push'); 

// VAPID keys should only be generated only once. 
const vapidKeys = webpush.generateVAPIDKeys(); 

webpush.setGCMAPIKey('<Your GCM API Key Here>'); 
webpush.setVapidDetails(
    'mailto:[email protected]', 
    vapidKeys.publicKey, 
    vapidKeys.privateKey 
); 

// This is the same output of calling JSON.stringify on a PushSubscription 
const pushSubscription = { 
    endpoint: '.....', 
    keys: { 
    auth: '.....', 
    p256dh: '.....' 
    } 
}; 

webpush.sendNotification(pushSubscription, 'Your Push Payload Text'); 

参照:セットアップウェブプッシュherehttps://github.com/web-push-libs/web-push

詳細なチュートリアル:

関連する問題