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 |1 Answer
Reset to default 0For 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.
本文标签:
版权声明:本文标题:firebase cloud messaging - Error Sending FCM v1 Notification: "The notification has no target applications" - 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736676183a1947193.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send
to send – Sampath Commented 2 days ago