Firebase HTTP POST推送返回200但设备未接收的问题咨询
Hey there, let’s break down why your Firebase push notifications are returning a 200 OK but failing to show up on devices, even though the Firebase Console works flawlessly. I’ve debugged this exact scenario multiple times, so here are the key culprits to check:
The Firebase Console automatically fills in default parameters that manual HTTP requests often skip. For example:
- If you’re only sending a
datapayload, Android devices won’t show a system notification by default when the app is in the background—you’ll need to manually handle it in yourFirebaseMessagingService’sonMessageReceivedmethod. - For
notificationpayloads, double-check you’re including bothtitleandbodyfields. A minimal valid payload looks like this:
{ "to": "YOUR_DEVICE_TOKEN", "notification": { "title": "Test Alert", "body": "This is a test notification" }, "priority": "high" }
Even with a 200 response, Firebase might be telling you the token is no longer valid via the canonical_ids field in the response body. For example:
{ "multicast_id": 123456789, "success": 1, "failure": 0, "canonical_ids": 1, "results": [ { "message_id": "0:123456%abc123def456", "registration_id": "NEW_VALID_TOKEN" } ] }
A canonical_ids value greater than 0 means your original token is obsolete—you need to replace it with the registration_id provided.
Default priority for manual HTTP requests is often normal, which can get throttled or delayed if the device is in power-saving mode or the app is in the background. The Firebase Console automatically sets high priority for visible notifications, so make sure you mirror this:
- For Android: Add
"priority": "high"directly in your payload. - For iOS: Include these headers in your request and configure the
apnssection in the payload:
{ "to": "YOUR_IOS_DEVICE_TOKEN", "notification": { "title": "iOS Test", "body": "iOS notification body" }, "apns": { "headers": { "apns-push-type": "alert", "apns-priority": "10" } } }
- Android: Ensure your app has the
POST_NOTIFICATIONSpermission (for Android 13+) and that yourFirebaseMessagingServiceis properly registered to handle messages. If sendingdatapayloads, you must explicitly build and show a notification inonMessageReceived. - iOS: Verify the user hasn’t disabled notifications for your app, and that you’ve enabled remote notification capabilities in Xcode. Also, confirm your
UNUserNotificationCenterDelegateis set up to handle foreground/background notifications.
Double-check that you’re using the correct Server Key from Firebase Console > Project Settings > Cloud Messaging (not a Web API key or other credential). Your request header should look like this:
Authorization: key=YOUR_VALID_SERVER_KEY Content-Type: application/json
A typo here will still sometimes return a 200, but the notification won’t be delivered.
If using a topic or condition, confirm the device is actually subscribed to that topic. For individual tokens, make sure you’re using the current token from the device—tokens can change after app reinstalls, OS updates, or when the user clears app data.
Pro tip: Use a tool like Charles or Fiddler to capture the request the Firebase Console sends, then compare it side-by-side with your manual HTTP request. The difference is almost always a missing field or incorrect parameter that’s easy to overlook.
内容的提问来源于stack exchange,提问作者Arthur Attout

