0
0
Firebasecloud~10 mins

Why push notifications engage users in Firebase - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize Firebase Cloud Messaging in your app.

Firebase
const messaging = firebase.[1]();
Drag options to blanks, or click blank then click option'
Amessaging
Bdatabase
Cauth
Dstorage
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'auth' or 'database' instead of 'messaging'.
2fill in blank
medium

Complete the code to request permission for push notifications from the user.

Firebase
Notification.[1]().then(() => console.log('Permission granted'));
Drag options to blanks, or click blank then click option'
AgetPermission
BrequestPermission
CallowPermission
DenablePermission
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like 'getPermission' or 'allowPermission'.
3fill in blank
hard

Fix the error in the code to correctly get the device token for push notifications.

Firebase
messaging.getToken({ vapidKey: '[1]' }).then(token => console.log(token));
Drag options to blanks, or click blank then click option'
AYOUR_PROJECT_ID
BYOUR_API_KEY
CYOUR_VAPID_KEY
DYOUR_APP_ID
Attempts:
3 left
💡 Hint
Common Mistakes
Using API key or project ID instead of VAPID key.
4fill in blank
hard

Fill both blanks to handle incoming push notifications and display a notification.

Firebase
messaging.onMessage(([1]) => {
  new Notification([2].notification.title);
});
Drag options to blanks, or click blank then click option'
Apayload
Bevent
Cmessage
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names for the event and the notification data.
5fill in blank
hard

Fill all three blanks to send a push notification message using Firebase Admin SDK.

Firebase
admin.messaging().[1]({
  [2]: '[3]',
  notification: {
    title: 'Hello',
    body: 'You have a new message!'
  }
});
Drag options to blanks, or click blank then click option'
Asend
Btoken
Cdevice_token
Dtopic
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'topic' instead of 'token', or wrong method name.