Complete the code to initialize Firebase Cloud Messaging in your app.
const messaging = firebase.[1]();The messaging() method initializes Firebase Cloud Messaging, which is used for push notifications.
Complete the code to request permission for push notifications from the user.
Notification.[1]().then(() => console.log('Permission granted'));
The requestPermission() method asks the user to allow push notifications.
Fix the error in the code to correctly get the device token for push notifications.
messaging.getToken({ vapidKey: '[1]' }).then(token => console.log(token));The vapidKey must be your public VAPID key to get the device token.
Fill both blanks to handle incoming push notifications and display a notification.
messaging.onMessage(([1]) => { new Notification([2].notification.title); });
The payload contains the notification data received, so it is used to access the title.
Fill all three blanks to send a push notification message using Firebase Admin SDK.
admin.messaging().[1]({ [2]: '[3]', notification: { title: 'Hello', body: 'You have a new message!' } });
The send method sends the message, the token field specifies the device token, and device_token is the placeholder for the actual token string.