Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize push notifications in the app.
HLD
PushNotificationManager.[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' or 'launch' which might sound correct but are not standard method names.
Confusing activation with initialization.
✗ Incorrect
The method to start push notification service is usually called 'initialize' to set up necessary configurations.
2fill in blank
mediumComplete the code to request user permission for push notifications.
HLD
NotificationService.request[1]Permission(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Requesting unrelated permissions like camera or microphone.
Confusing push permission with location permission.
✗ Incorrect
To receive push notifications, the app must request 'Push' permission from the user.
3fill in blank
hardFix the error in the code to handle incoming push notifications.
HLD
PushNotificationManager.onNotificationReceived = function([1]) { console.log('Notification:', [1].message); };
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a parameter name that does not match the object used inside the function.
Using generic names like 'event' or 'msg' that cause confusion.
✗ Incorrect
The function parameter should be named 'notification' to clearly represent the incoming notification object.
4fill in blank
hardFill both blanks to subscribe the user to a topic and handle errors.
HLD
PushNotificationManager.subscribeToTopic([1]) .then(() => console.log('Subscribed to topic')) .catch([2] => console.error('Subscription error:', [2]));
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-string value for the topic name.
Using inconsistent error parameter names.
✗ Incorrect
The topic name should be a string like 'news-updates'. The error handler parameter is commonly named 'error' to represent the error object.
5fill in blank
hardFill all three blanks to create a notification payload and send it.
HLD
const payload = {
title: [1],
body: [2],
priority: [3]
};
PushNotificationManager.sendNotification(payload); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-string values for title or body.
Setting priority to 'low' when high priority is needed.
✗ Incorrect
The title and body are strings describing the notification. Priority is set to 'high' to ensure prompt delivery.
