Can't Send Push Notifications Using the Server API

Can't send push notifications using the server API

On iOS the priority field seems mandatory.

{   
"to": "cHPpZ_s14EA:APA91bG56znW...",
"priority": "high",
"notification" : {
"body" : "hello!",
"title": "afruz",
"sound": "default"
}
}

Failed to send the FCM push notification using the REST API

There's a Line Feed (LF) character in your URL (%0A after URL encoding) which is not valid API URL. That may have been added while copying from the documentation or other source.

The URL should be /fcm/send instead of /fcm/send%0A.

Firebase API is not sending push notifications when using the API

I got contacted by Firebase support and was able to find out what is wrong

My push payload was missing a notification object

{ 
"to": "<registration token>",
"priority": "high",
"notification": {
"title": "Your Title",
"text": "Your Text"
}
"data": {
"customId": "<my custom id>",
"badge": 1,
"sound": "cheering.caf",
"alert": "New data is available"
}
}

I hope that helps someone else

FCM push notification via AlamoFire - URLSessionTask failed with error: Could not connect to the server

Even though I do not recommend sending an FCM request straight from the app, it appears you have a typo in your server URL address.

Just change it to https://fcm.googleapis.com/fcm/send

Why I can't send a push notification using the Appcelerator REST API in C#?

I found the way to do this. First I have to login and save the session in a CookieContainer like this:

    public void Login()
{
client = new RestClient("https://api.cloud.appcelerator.com");
client.CookieContainer = new System.Net.CookieContainer();
request = new RestRequest("/v1/users/login.json?key={appkey}", Method.POST)
{
RequestFormat = DataFormat.Json,
};
request.AddUrlSegment("appkey", "key");
request.AddBody(new
{
login = "user",
password = "pass"
});
var response = client.Execute(request);
SendPush();
}

Then I make a call to my SendPush method which looks like this now:

    public void SendPush()
{
try
{
client.BaseUrl = "https://api.cloud.appcelerator.com";
request.Resource = "/v1/push_notification/notify.json?key={appkey}";
request.Method = Method.POST;
request.AddUrlSegment("appkey", "key");

request.AddParameter("channel", "alert");
request.AddParameter("payload", "{ \"title\" : \"notificación\", \"badge\" : 1, \"alert\" : \"alerta: Sismo detectado en: " + direccion + " proximo arribo de sismo a la ciudad de mexico\", \"sound\" : \"default\"}");
var response = client.Execute(request);
}
catch (Exception ex)
{
Debug.WriteLine("Message " + ex.Message + " \n Inner Exception " + ex.InnerException + " \n Stack Trace" + ex.StackTrace);
}
}

I was having trouble sending the payload object in the AddBody method, so I decided to send it as a string with AddParameter and it worked with no problem, this can be done too using the JavaScriptSerializer or JsonConverter from JSON.NET. Hope it helps other people.

Can't send firebase notification via Android but it works via curl

It worked when I used the "Legacy server key" within Android making a rest call.
But with curl I use the "Server key" and it works fine.
Don't know why.

Can't send notification [error: 80300002] (HMS Core Push Kit) - Web App

Please create an Android application under the project of the web application, and obtain the access_token with the appid and appsecret of the Android app. Then the access_token can be passed into the send interface.



Related Topics



Leave a reply



Submit