I am trying to send Firebase notifications to multiple devices from an API written in PHP. It is sending notifications to android devices without any issue but this is not the case for ios devices.
Here is the payload for android:
{
"registration_ids": [
"d-Ao4YZ1V_E:APA91bFzT1Es9VhDX4OC_2zOV4RWmDXQ-PP24Za-D-uXAwyWdrd2W3bQkHAc3M1uwYKXTDiWix5teBwfTHbRmHcMbz5q39OCNsGgtgH_n0wxyo0ceL2ZfA8y7o3D0cXDLv2iVMjhmHAA5sVJUOBhfXf-mbzw7E2hog",
"eRetdkDVHvY:APA91bEzUKrnK5cHskxOGTlHZtxYjXsxPyRlj8XRNVOcoX-8aCfY7z0cU0yFVGplBiONqSEV8wtslmW6sDXGodiirS0oKDPUzAaAT91Su5Yrnzs1XHHlfJA6rQurp941rC0hKJ8vd_e9JcfjihlGP36Cu3Tpb3hELw"
],
"data": {
"title": "Producer",
"text": "Setting Check",
"notification": {
"NotificationID": "5864",
"NotificationType": "",
"Title": "Producer",
"Text": "Setting Check"
},
"sound": "true"
},
"content_available": true,
"priority": "high"
}
Here is my payload for ios devices:
{
"registration_ids": [
"dsMZdthHp6E:APA91bH8UcvSiEjlk9b6QRwrWiCWz65k5i-CxKLB3LGqHdz7FG7gPWHRwnNBtsvdWZLg_9Fx8lRFOKyf17XKEm_mdbRAGzni6wbsogDdiG_ARQxCAm8qVD0iaQKvB_tosWcukLLVu3qrbZxc3BjmSvGjeNJaBAcHkQ",
"eXhFfdy9oO4:APA91bGp3bMu-ps6euvBTDW5HshAIgdswFUgZ6p7EIFeW7abHMz2uIwmzzZuqz0bEwEAGi2fGLb0JJ4bhKhoGAs0EH4yqd0WDVkVH9Je6b7q9WFzBDDF__jIGoF1ShdM8qoqnVbeJmOSf3bS7s89xKmUh_m2x0ecQg" ],
"notification": {
"title": "Custom Notification",
"text": "This custom notification is sent through Vendors area. Let's see if it works?",
"sound": "default"
},
"data": {
"notification": {
"Title": "Producer",
"Text": "Setting Check"
},
"title": "Producer",
"text": "Setting Check"
},
"content_available": true,
"priority": "high"
}
The issue is with payload but I can't seem to locate the issue.I am new to fire base. Please help me sorting this out.
Related
I trying to update sended push, using collapse mechanism.
I read many docs and info about it, but failed to achieve significant results.
It is work only for Android. I need in iOS too.
What i send to firebase:
{
"registration_ids": [
"CE2BSR7TwxPY . . . gbWKvBu3SFWh9dHECOIQT6v"
],
"data": {
"pushId": null,
"target": "screen",
"value": "main",
},
"notification": {
"title": "Some title..6",
"body": "2 push apns-collapse-id. 30 attempt",
"sound": "default",
"mutable-content": 1,
"badge": 0,
"tag": "test"
},
"apns": {
"headers": {
"apns-collapse-id": "test"
}
},
"collapse_key": "test"
}
I send 2 pushes with the same collapse_key
And result:
enter image description here
This is iOS 12+. On another iPhones is the same result.
where did i go wrong?
Collapse this even possible on iOS?
I've implemented Silent push notification, but it has a sound like the normal ones. Help me to correctly implement this.
Here's the payload that we're sending from Backend to FCM:
{
"notification": {
"messageId": "24d0f68a24d"
},
"content_available": true,
"data": {
"requestId": "231DDD",
"messageId": "f68a24d",
"event": "REMOVE_NOTIFICATION",
"message": ""
},
"apns": {
"headers": {
"apns-push-type": "background",
"apns-priority": 5
}
},
"to": "FCM_Token",
"priority": "high"
}
To make this silent, you have to remove following part.
"notification": {
"messageId": "24d0f68a24d"
},
I have an in house application where I have the criticalAlert option setup within my application. I have confirmed that when I send the following with the pushy application, I am able to get the Critical Alert to work on the iOS application.
The issue is our internal server currently only sends the notifications to the Firebase Cloud Messaging, and I'm not able to configure the raw push payload to play the critical alert on the device.
Here is the example that Apple gave on how the push should look to APNS:
Here is what I send using the pushy app that works on the application:
{
"aps" : {
"content_available": true,
"priority": "high",
"alert" : "Your message Here",
"badge" : 1,
"sound": {
"critical": 1,
"name": "alert.wav",
"volume": 1.0
},
"data": {
"volume": 7,
"time_to_live": 900,
"id": 3618,
"type": "engagement",
"overrideMessage": "Testing oncall for iOS",
"case": "Test Case",
"repeatNumber": 3,
"customer": "Google"
}
}
}
Here is the current payload that we send to FCM and it works with the custom sound, but we really want the critical alert to be working since the push is for an on-call engagement:
{
"to": "firebaseToken",
"content_available": true,
"priority": "high",
"isCritical": "true",
"notification": {
"title": "Title in notification",
"body": "Body in notification",
"sound": "alert.wav",
"badge": "1",
"subtitle": "subtitle in notification"
},
"data": {
"volume": 7,
"time_to_live": 900,
"id": 3618,
"type": "engagement",
"overrideMessage": "Testing oncall for iOS",
"case": "Test Case",
"repeatNumber": 3,
"customer": "Google"
}
}
I have tried a large number of combinations on what to send to FCM but with no luck:
{
"to": "firebaseToken",
"apns": {
"headers": {
"apns-priority": "10"
},
"payload": {
"aps" : {
"sound": {
"critical": 1,
"name": "alert.wav",
"volume": 0.5
},
and
{
"aps" : {
"to": "firebaseToken",
"content_available": true,
"priority": "high",
"alert" : "Your message Here",
"badge" : 1,
"sound": {
"critical": 1,
"name": "alert.wav",
"volume": 0.5
},
and
{
"to": "firebaseToken",
"aps" : {
"sound" : {
"critical": 1,
"name": "alert.wav",
"volume": 1.0
}
},
"notification": {
"badge": "1",
and
{
"to": "firebaseToken",
"isCritical": "true",
"content_available": true,
"notification": {
"badge": "1",
"sound" : {
"critical": 1,
"name": "alert.wav",
"volume": 1.0
},
None of them have allowed the sound dictionary to be passed on to FCM.
I have also the the answer here but it doesn't solve my problem. as I require iOS to know that this push notification is critical and have the OS handle it and not my application.
Before I give the answer to your specific question, I'd like to recommend that you consider using the Admin SDK instead of the REST API if possible. The SDK is available in Node.js, Java, python, go, and C#. If your server code is written in any of those languages, this is a much simpler way to handle sending messages with FCM. The SDK handles retries and other scenarios you would otherwise have to implement into your code.
As for your question, it's noted in the guides that platform-specific fields only work with the FCM v1 endpoint. To use FCM, your endpoint will look like this:
https://fcm.googleapis.com/v1/projects/[your-project-id]/messages:send
You can see an example of this in the guides. Select REST from the snippet tab to see the example.
Note that the way you authorize sends is different with V1. You can find out more in the guide. If you have trouble with the auth part, I also wrote a blog post about it since it comes up pretty regularly.
I am trying to send test push from Urban Airship portal. I have got channel ID of device, created JSON payload. However when I am trying to send, it always show error, Sorry, this doesn't look like valid JSON. Below is my Payload data, please help me in this.
{
"audience": {
"ios_channel": "938a3a93-1a5f-466c-923b-827ef4b0a75b"
},
"notification": {
"aps": {
"alert": {
"body": "Sample",
"title": "Sample"
}
}
"ios": {
"badge": 3
}
},
"device_types": [
"ios"
]
}
This valid , you forget a comma , you may use https://jsonlint.com for such things
{
"audience": {
"ios_channel": "938a3a93-1a5f-466c-923b-827ef4b0a75b"
},
"notification": {
"aps": {
"alert": {
"body": "Sample",
"title": "Sample"
}
},
"ios": {
"badge": 3
}
},
"device_types": [
"ios"
]
}
Hi I am developing ionic app for android and IOS but I am facing issue with push notification. My notification status as below
"data": [
{
"config": {
"query": {
"$and": [
{
"details.email": {
"$regex": "prit"
}
}
]
},
"notification": {
"title": "Test Push",
"payload": {},
"android": {
"title": "Test Push",
"priority": "high",
"message": "Get 150% off!cxzczxcxzc"
},
"ios": {
"title": "Test Push",
"priority": 10,
"message": "Get 150% off!cxzczxcxzc"
},
"message": "Get 150% off!cxzczxcxzc"
},
"profile": "dev"
},
"created": "2017-03-07T10:19:07.563387+00:00",
"status": "locked",
"uuid": "82a2a7be-b7ad-41c3-abca-d5243b040c76",
"state": "enqueued",
"app_id": "1e54f22e"
},
],
"meta": {
"version": "2.0.0-beta.0",
"status": 200,
"request_id": "d70268c5-3875-4e78-cef6-a17927b04917"
}
}
here state is in enqueued ("status": "locked") and "status": "locked",.
I am not understanding its meaning. due to this I am not able to receive the any push notification. Please let me know how I can resolve this issue.