Is it available to pass interruption-level (iOS) through firebase cloud message? - firebase-cloud-messaging

Trying to send push notification throug FCM using
POST https://fcm.googleapis.com/fcm/send
Is a way to send interruption-level to aps on push notification?

According to the HTTP API spec you can provide the APNS payload via apns key in JSON with the appropriate values:
{
"apns": {
"payload": {
"aps": {
"interruption-level": "active"
}
... other APNS-specific keys such as alert, title
}
},
... your other keys such as targeting
}
Note that for some interruption-level values to work (critical or time-sensitive) you need to have the app signed with the correct entitlements.

Related

WhatsApp Business Platform API using Test account doesn't send the message to Mobile

I have created a WhatsApp Business Platform Test account. I am able to send and receive the hello-world template message but when I send a test message without template(as specified by the api) it doesn't push it to the mobile phone. Strangely I get success response in both cases.
Url: https://graph.facebook.com/v15.0/11ZZZZZZZZZZZZZ/messages
Here are the jsons and their responses
{
"messaging_product":"whatsapp",
"to":"91ZZZZZZZZZZ",
"type":"template",
"template":{
"name":"hello_world",
"language":{
"code":"en_US"
}
}
}
{
"messaging_product":"whatsapp",
"contacts":[
{
"input":"91ZZZZZZZZZZ",
"wa_id":"91ZZZZZZZZZZ"
}
],
"messages":[
{
"id":"wamid.HBgMOTE3MjkwMDIxMzYwFQIAERgSMjZCRkQ3RDc0RjM0QkNEZZZZZZ=="
}
]
}
In these case I successfully receive message on the mobile
{
"messaging_product":"whatsapp",
"to":"91ZZZZZZZZZZ",
"type":"text",
"text":{
"preview_url":false,
"body":"Hello World Testing"
}
}
{
"messaging_product":"whatsapp",
"contacts":[
{
"input":"91ZZZZZZZZZZ",
"wa_id":"91ZZZZZZZZZZ"
}
],
"messages":[
{
"id":"wamid.HBgMOTE3MjkwMDIxMzYwFQIAERgSQUJERkM2RUE1RTEwQTExZZZZZZ=="
}
]
}
However I don't receive message on the mobile.
Is there anything I am missing in the second case?
I was strugging with the same problem, but I figured out that you need to reply back to your first template message with a 'hello' or any kind of reply. Once you reply, only then can you send a message through that watsapp api without a template, or you can inititate conversation through watsapp api.
Hope this answer helps you.

Which attribute should I use when push message in Firebase Cloud Messaging, 'text' or 'body'?

I have been using push notification in Google Firebase Cloud Messaging API since 2016. But I got issue on 7th of January in 2020, and since then it doesn't work.
I'm finding right attribute for the API parameter.
Previously : 'notification' => ['text'=> $action]
Changed (work) : 'notification' => ['body'=> $action]
Is body the right parameter?
If not how can I find the right parameter ?
The documentation shows this example of a message body:
{
"message":{
"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"notification":{
"body":"This is an FCM notification message!",
"title":"FCM Message"
}
}
}
So it looks like body is indeed the proper name for the property to use.

Figuring out which FCM tokens are expired from a firebase response with several registration ids

Firebase rest endpoint for push notifications lets you send a message to several people at once by passing the tokens through "registration_ids" array instead of "to". When the response comes back it looks like this:
{
"multicast_id":000000000000000000,
"success":1,
"failure":4,
"canonical_ids":0,
"results":[
{
"error":"NotRegistered"
},
{
"error":"NotRegistered"
},
{
"error":"NotRegistered"
},
{
"error":"NotRegistered"
},
{
"message_id":"0:0000000000000000%a0a0a0aaa0a0a0aa"
}
]
}
How are you supposed to correlate the NotRegistered errors to a particular token it was sent to?
The results are in the same order as you specified them in the request. So only your last token was valid.

Firebase Cloud Messaging topic send, message does not show in Notifications and is never sent

I am using the REST api and I am trying to send to a topic. I know the topic exists because I can see in the Notification console that the topic is there. And I can send a test message through the console and that works.
However, when I use the REST api, I get an http status 200 response with json {"message_id":8769790390495267408} which looks like a successful send. However, the message does not show up in Notifications and the message is not sent to subscribed clients.
My message looks like, which is from the docs
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to": "/topics/foo-bar",
"data": {
"message": "This is a Firebase Cloud Messaging Topic Message!",
}
}
And I am using the "Server key" and not the Web api key.
Thanks for any help.
For iOS, try using notification instead of data. Then add in the priority and set it to high. The payload should look something like this:
https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to": "/topics/foo-bar",
"priority": "high",
"notification" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark",
"icon" : "myicon"
}
}

GCM Unauthorized Error 401

I'm not able to get response from GCM even i'm providing correct server API key generated by google.
Problem : I want to make a push notification using GCM from my sails app.
I'm posting below code to "https://android.googleapis.com/gcm/send"
Code : 1
{
"headers":{
"Content-Type":"application/json",
"Authorization":"key=xxxxxxxxxxxxxxxxxxxx"
},
"notification":{
"title":"Hello Notify",
"text":"Notification By Sails"
},
"registration_ids":["xxxxxxxxxxxx","xxxxxxxxxxxx","xxxxxxxxxxxx"]
}
Code : 2
{
"headers":{
"Content-Type":"application/json",
"Authorization":"key=xxxxxxxxxxxxxxxxxxxx"
},
"body":{
"notification":{
"title":"Hello Notify",
"text":"Notification By Sails"
}
},
"registration_ids":["xxxxxxxxxxxx","xxxxxxxxxxxx","xxxxxxxxxxxx"]
}
I'm getting response as below.
"statusCode": 401,
"body": "<HTML>\n
<HEAD>\n<TITLE>Unauthorized</TITLE>\n</HEAD>\n
<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\">\n
<H1>Unauthorized</H1>\n
<H2>Error 401</H2>\n
</BODY>\n
</HTML>\n",
The headers should be HTTP headers, not element in the payload.
Make sure you have enabled the right API in Cloud Console. If sending with a Server API key, you need to have "Google Cloud Messaging for Android" enabled.