0
0
Firebasecloud~10 mins

Firebase Admin SDK (Node.js) - Interactive Code Practice

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

Complete the code to initialize the Firebase Admin SDK.

Firebase
const admin = require('firebase-admin');

admin.[1]();
Drag options to blanks, or click blank then click option'
AlaunchApp
BinitializeApp
CinitFirebase
DstartApp
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method name that does not exist like startApp or launchApp.
Forgetting to call the method as a function.
2fill in blank
medium

Complete the code to get a Firestore database instance.

Firebase
const db = admin.[1]();
Drag options to blanks, or click blank then click option'
Adatabase
BgetDatabase
CgetFirestore
Dfirestore
Attempts:
3 left
💡 Hint
Common Mistakes
Using getFirestore() which is not a method on admin directly.
Using database() which is for Realtime Database, not Firestore.
3fill in blank
hard

Fix the error in the code to send a message using Firebase Cloud Messaging.

Firebase
const message = { token: userToken, notification: { title: 'Hello', body: 'World' } };

admin.messaging().[1](message)
  .then(response => console.log('Sent:', response))
  .catch(error => console.error('Error:', error));
Drag options to blanks, or click blank then click option'
Asend
Bpublish
CsendMessage
Ddispatch
Attempts:
3 left
💡 Hint
Common Mistakes
Using sendMessage which does not exist in the Admin SDK.
Using publish or dispatch which are not Firebase methods.
4fill in blank
hard

Fill in the blank to create a new user with email and password using Firebase Admin SDK.

Firebase
admin.auth().[1]({ email: userEmail, password: userPassword })
  .then(userRecord => console.log('User created:', userRecord.uid))
  .catch(error => console.error('Error:', error));
Drag options to blanks, or click blank then click option'
AregisterUser
BaddUser
CcreateUser
DnewUser
Attempts:
3 left
💡 Hint
Common Mistakes
Using addUser or registerUser which are not valid Admin SDK methods.
Using newUser which does not exist.
5fill in blank
hard

Fill in the two blanks to update a user's display name and photo URL.

Firebase
admin.auth().updateUser(userId, { displayName: [1], photoURL: [2] })
  .then(userRecord => console.log('Updated user:', userRecord.uid))
  .catch(error => console.error('Error:', error));
Drag options to blanks, or click blank then click option'
A'New Name'
B'https://example.com/photo.jpg'
CuserId
D'Anonymous'
Attempts:
3 left
💡 Hint
Common Mistakes
Using userId as a value for displayName or photoURL.
Not using quotes around string values.