How to see number of recipients for FCM - android

I make a request to https://fcm.googleapis.com/fcm/send with the following json data:
{
"to": "/topics/push_topic",
"data" : {
"language": "tr,en_us",
"ticker": "...",
"tickerEnglish": "...",
"body": "...",
}
}
The response I receive is the following (The message is sent successfully):
{
"message_id": xxxxxxxxxxxxx
}
But according to the documentation, I am supposed to receive a response like the following:
{
"multicast_id": 216,
"success": 3,
"failure": 3,
"canonical_ids": 1,
"results": [
{ "message_id": "1:0408" },
{ "error": "Unavailable" },
{ "error": "InvalidRegistration" },
{ "message_id": "1:1516" },
{ "message_id": "1:2342", "registration_id": "32" },
{ "error": "NotRegistered"}
]
}
So, why can't I see success and failure variables in my response? Is that because I send the message to a topic?
Thanks.

This is the expected response when sending to a topic.
The sample response with multiple results is for when you are using the registration_ids parameter when sending the message payload.

Related

Firebase Post Request, getting Missmatch Sender ID, Where to put Sender Id in Request?

I am trying to create a post request for sending firebase push notifications (trying on postman) and I am getting MismatchSenderId:
{
"multicast_id": 4548549053367743061,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [
{
"error": "MismatchSenderId"
}
]
}
I have sender id from firebase console:
But i dont know how to put it in my starting request which is like this:
{
"to": "************************ server Key from firebase project settings",
"message":{
"notification":{
"title":"Portugal vs. Denmark",
"body":"great match!"
},
}
}
And headers look like this:

How to handle unknown response type with Retrofit

I am new to Retrofit and GSON
before retrofit, I have created a custom class for API calls, and map data manually.
This is my standard Response Type
{
"timestamp",
"status",
"message",
"payLoad",
"error"
}
If I GET the error from the server so my response is like
{
"timestamp":123456789,
"status":302,
"message":"Send All Data",
"error":"Partial Content"
}
If I get Success but Payload IS JSONObject so response like
{
"timestamp":123456789,
"status":200,
"message":"Save Successfully",
"payLoad":"{
"token": "...",
"userDetails": {
"id": 1,
"username": "...",
"firstName": "Deepak",
"lastName": "Gupta",
"gender": "MALE",
"address": ...,
"demoModel": {
"id": 1,
"demo": "enginner",
"demoConstant": "ENGINNER",
"active": true
},
"registrationDate": 1585831235533,
"enabled": true,
"expireTime": 4178010611915}
}
If I get Success but Payload IS JSONArray so response like
{
"timestamp": 1586330473808,
"status": 200,
"message": "SUCCESS",
"payLoad": [
{
...
},{
...
},{
...
}
]
}
I tried to make Payload to Object and then using InstanceOf I'll cast to respective model or List but then getting error linkedtreemap not cast to list or Object.

Getting issue in get id from youtube API

I am trying to get Id from Youtube API in android app but unable to find
https://www.googleapis.com/youtube/v3/channels?part=id&forUsername={username}&key={YOUR_API_KEY}
But getting this response:
{
"kind": "youtube#channelListResponse",
"etag": "\"sNu6csVZt536JdlmpOxN9WQSd8U/ewwRz0VbTYpp2EGbOkvZ5M_1mbo\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": []
}
I have also tried with this
https://www.googleapis.com/youtube/v3/channels?part=id%2CcontentDetails&mine=true&key={YOUR_API_KEY}
But a response is below:
{
"error": {
"errors": [
{
"domain": "youtube.parameter",
"reason": "authorizationRequired",
"message": "The request uses the \u003ccode\u003emine\u003c/code\u003e parameter but is not properly authorized.",
"locationType": "parameter",
"location": "mine"
}
],
"code": 401,
"message": "The request uses the \u003ccode\u003emine\u003c/code\u003e parameter but is not properly authorized."
}
}
make sure you are logged-in with OAuth when performing these calls and if you're going to parse the JSON response to look for the id, it's found in items.id
Tried this with Channels.list Try-it and I got correct response:
/**
* API response
*/
{
"kind": "youtube#channelListResponse",
"etag": "\"VPWTmrH7dFmi4s1RqrK4tLejnRI/X6OHzHqUUEu1okILXdfdfBbUxU\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"VPWTmrH7dFmi4s1RqrK4tLejfdf/Qw3dXynuD_IdfB1LMKjSeiDI\"",
"id": "UCTjdfopNLdfd5yXVv93Ww"
}
]
}

FCM Diagnostics Invalid Message ID?

I am using GCM to send push messages to multiple users, but even though I am getting success and message IDs in the response, I cannot debug them in FCM diagnostics and they don't arrive to the devices.
How can I debug this?
The message I'm sending:
{
"priority": "normal",
"time_to_live": 6000,
"delay_while_idle": true,
"content_available": true,
"notification": {
"title": "Title",
"text": "Text",
},
"data": {
"title": "Title",
"text": "Text",
},
"registration_ids": ["ID1", "ID2"]
}
The response is an array of message IDs.

Parse JSON with facebook sdk

I was wondering how to get the value of "name" for the following json text with facebook sdk. Assuming I have already got the access token. Any thoughts? Many thanks!
enter code here
{
"id": "100005065353669",
"music": {
"data": [
{
"category": "Musician/band",
"name": "Eason Chan",
"id": "105468519487919",
"created_time": "2013-06-05T20:33:26+0000"
}
],
"paging": {
"next": "https://graph.facebook.com/100005065353669/musiclimit=5000&offset=5000&__after_id=105468519487919"
}
}
}

Categories

Resources