0
I downloaded a project to test sending push notification. I am trying in various ways and without success. This project is from a guy named Habibali. When I spin it gives the error of
Unauthorized
This is the program code for sending notifications
using System.Threading.Tasks;
using FirebaseNet.Messaging;
using System;
namespace MessageSender
{
class MessageSender
{
static void Main(string[] args)
{
Task t = new Task(async () =>
{
await foo();
});
t.Start();
Console.ReadLine();
}
public static async Task<IFCMResponse> foo()
{
FCMClient client = new FCMClient("AIzaSyAmf6JBNd2f0n4De-1DdPJdJiWfDbGhDVI"); //as derived from https://console.firebase.google.com/project/
var message = new Message()
{
To = "778532852741", //topic example /topics/all
Notification = new AndroidNotification()
{
Body = "great match!",
Title = "Portugal vs. Denmark",
}
};
var result = await client.SendMessageAsync(message);
return result;
}
}
}
The FCM program is running on my Cel(Rodei this morning) and also I can not anymore. As it was deployed the first time, it’s working, but I can’t run it anymore, I even opened a post for this.
This may be a problem with the serverKey generated in Firebase. I’ve never used Xamarin, so I’m not able to help you so much. =/
– viana
100% chance it’s the server key. You have to create a project for your app in firebase, take the json file it generates and put it in the project root. Then take the server key that was generated for you and swap in the Fcmclient constructor. Follow the tutorial you have for java that in Xamarin is the same thing. Or change pro Onesignal that does the same thing.
– Grupo CDS Informática
Take a look at this Issue: https://github.com/rlamasb/Firebase.Xamarin/issues/25
– viana
@Grupocdsinformática, this Onesignal is what. An outgoing environment or message server? You said to get the generated json. And where do I get this file? Where is it? Isn’t the google-service. is?
– pnet
In the author’s own Github he teaches how to configure the whole push notification process: https://github.com/HabibAli/FCM-Xamarin-Forms
– Gabriel Coletta
I was mounting step by step, removing the errors and when no more error, gives the error of: An unhandled Exception ocurred. My app consumes a service.
– pnet
@Grupocdsinformática, I put what? The SENDER_ID or PROJECT_ID? and the KEY API is this(Web API key)? When I created the project appeared a great key called Server Key, but I can’t find it in firebase anymore, I think that’s right?
– pnet
If I’m not mistaken eh a Key server, but if you enter the project settings (think eh gear) there have, in cloud messaging.
– Grupo CDS Informática
@Grupocdsinformática, is the same server key. I have confirmed, any value other than it gives this error. Only I even opened another post, as it is now giving invalid registry error.
– pnet