A. getToken() returns a Future, so it must be awaited
B. token cannot be null, so ! is unnecessary
C. FirebaseMessaging.instance is not initialized
D. print statement syntax is incorrect
Solution
Step 1: Check getToken() return type
getToken() returns a Future, so it must be awaited to get the actual token.
Step 2: Identify missing await
Code assigns Future to String? without await, causing error.
Final Answer:
getToken() returns a Future, so it must be awaited -> Option A
Quick Check:
Async methods need await to get values [OK]
Hint: Async calls must use await or then() [OK]
Common Mistakes:
Ignoring async nature of getToken()
Using ! without checking for null
Assuming instance is uninitialized without reason
5.
You want to show a local notification when a push notification arrives while the app is in the foreground. Which approach correctly combines FirebaseMessaging with Flutter Local Notifications?
hard
A. Use FirebaseMessaging.subscribeToTopic to trigger local notifications automatically
B. Only use FirebaseMessaging.getToken to show notifications
C. Listen to FirebaseMessaging.onMessage and call local notification plugin to display notification
D. Call local notifications plugin inside FirebaseMessaging.getInitialMessage