admin管理员组

文章数量:1125950

I'm using Google Firebase Cloud Messaging (FCM) v1 API to send notifications. I have configured my project with the following details:

Private Key
Client Email
Project ID

Response : { "message": "Error sending notification: The notification has no target applications. The notification format is gcm. Review the credentials specified in the notification hub description and the notification format.. TrackingId:5da2a253-53eb-4416-9655-80da98ea8a0b,TimeStamp:1/8/2025 8:01:16 AM +00:00" }

I am trying to send a notification to an Android device using the Firebase Cloud Messaging (FCM) v1 API. Despite configuring the private key, client email, and project ID correctly, I receive an error stating, "The notification has no target applications." I want to ensure that the notification reaches any Android device successfully. How can I resolve this issue and make sure the notification is sent to the intended devices?

I'm using Google Firebase Cloud Messaging (FCM) v1 API to send notifications. I have configured my project with the following details:

Private Key
Client Email
Project ID

Response : { "message": "Error sending notification: The notification has no target applications. The notification format is gcm. Review the credentials specified in the notification hub description and the notification format.. TrackingId:5da2a253-53eb-4416-9655-80da98ea8a0b,TimeStamp:1/8/2025 8:01:16 AM +00:00" }

I am trying to send a notification to an Android device using the Firebase Cloud Messaging (FCM) v1 API. Despite configuring the private key, client email, and project ID correctly, I receive an error stating, "The notification has no target applications." I want to ensure that the notification reaches any Android device successfully. How can I resolve this issue and make sure the notification is sent to the intended devices?

Share Improve this question asked Jan 9 at 2:50 Arpit SoniArpit Soni 11 bronze badge New contributor Arpit Soni is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 1
  • use POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send to send – Sampath Commented 2 days ago
Add a comment  | 

1 Answer 1

Reset to default 0

For HTTP v1 send requests, you need to include an OAuth 2.0 access token in the header as Authorization: Bearer <valid OAuth 2.0 token>.

Refer to this guide to use the FCM HTTP v1 API with OAuth 2.0 access tokens, along with the Android app setup.

POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1

Content-Type: application/json
Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA

{
   "message":{
      "token":"APA91bGHXQBB...9QgnYOEURwm0I3lmyqzk2TXQ",
      "data":{
        "hello": "This is a Firebase Cloud Messaging device group message!"
      }
   }
}
curl -X POST -H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
  "message": {
    "token": "DEVICE_REGISTRATION_TOKEN",
    "notification": {
      "title": "Test Notification",
      "body": "This is a test."
    }
  }
}' https://fcm.googleapis.com/v1/projects/<PROJECT_ID>/messages:send

using python

import requests
import json
url = "https://fcm.googleapis.com/v1/projects/<PROJECT_ID>/messages:send"
headers = {
    "Authorization": "Bearer <ACCESS_TOKEN>",
    "Content-Type": "application/json"
}
data = {
    "message": {
        "token": "DEVICE_REGISTRATION_TOKEN",
        "notification": {
            "title": "Test Notification",
            "body": "This is a test."
        }
    }
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.status_code)
print(response.json())



Device group messaging allows you to add multiple devices to a single group. Refer to this link for instructions on how to send messages to device groups on Android.

本文标签: