Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to send a notification message with a title.
Firebase
const message = { notification: { title: '[1]' } }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number or boolean instead of a string for the title.
Leaving the title empty or null.
✗ Incorrect
The title field in a notification message must be a string, like 'Hello World'.
2fill in blank
mediumComplete the code to send a data message with a key-value pair.
Firebase
const message = { data: { [1]: '12345' } }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using notification keys inside data messages.
Using reserved keys like 'notification' inside data.
✗ Incorrect
Data messages use custom keys like orderId to send data.
3fill in blank
hardFix the error in the message object to correctly send a notification with data.
Firebase
const message = { notification: { title: 'Sale' }, [1]: { discount: '20%' } }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Repeating 'notification' instead of using 'data'.
Using incorrect field names like 'payload' or 'message'.
✗ Incorrect
The data field is used to send custom key-value pairs alongside notification.
4fill in blank
hardFill both blanks to create a message with notification title and data key.
Firebase
const message = { [1]: { title: 'Update' }, [2]: { version: '1.2.3' } }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping 'notification' and 'data' fields.
Using incorrect field names like 'payload' or 'message'.
✗ Incorrect
The notification field holds the visible message, and data holds extra info.
5fill in blank
hardFill all three blanks to send a notification with title, body, and data key.
Firebase
const message = { [1]: { title: 'Alert', [2]: 'Check your app' }, [3]: { alertId: '789' } }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting 'body' as a separate top-level field.
Using 'payload' instead of 'data'.
✗ Incorrect
The notification field contains title and body. The data field holds extra info.