You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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:

1. Your payload structure is missing critical fields

The Firebase Console automatically fills in default parameters that manual HTTP requests often skip. For example:

  • If you’re only sending a data payload, 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 your FirebaseMessagingService’s onMessageReceived method.
  • For notification payloads, double-check you’re including both title and body fields. A minimal valid payload looks like this:
{
  "to": "YOUR_DEVICE_TOKEN",
  "notification": {
    "title": "Test Alert",
    "body": "This is a test notification"
  },
  "priority": "high"
}
2. Your device token is outdated or invalid

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.

3. You’re not setting the correct message priority

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 apns section 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"
    }
  }
}
4. Device-side permissions or handling are misconfigured
  • Android: Ensure your app has the POST_NOTIFICATIONS permission (for Android 13+) and that your FirebaseMessagingService is properly registered to handle messages. If sending data payloads, you must explicitly build and show a notification in onMessageReceived.
  • iOS: Verify the user hasn’t disabled notifications for your app, and that you’ve enabled remote notification capabilities in Xcode. Also, confirm your UNUserNotificationCenterDelegate is set up to handle foreground/background notifications.
5. Your server key or request headers are incorrect

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.

6. You’re targeting the wrong device/topic

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:06:25