bytefish / FcmSharp

Firebase Cloud Messaging (FCM) with .NET
MIT License
6 stars 7 forks source link

Nothing happens after sending the notification #19

Closed allistoncarlos closed 6 years ago

allistoncarlos commented 6 years ago

My iOS app is configured with Firebase, and I can send notifications using the console, but when I try to send using the backend, nothing happens...

Here's my code:

var settings = FileBasedFcmClientSettings.CreateFromFile(project, credentialsFileName);

        using (var client = new FcmClient(settings))
        {
            var data = notification.ToDictionary();

            var message = new FcmMessage
            {
                ValidateOnly = false,
                Message = new Message
                {
                    // { "body": "Test", "Title": "Testing" }
                    Data = data,
                    Topic = "all-topic"
                }
            };

            var cts = new CancellationTokenSource();

            var result = client.SendAsync(message, cts.Token).GetAwaiter().GetResult();
        }

The code returns the following string, but the notification doesn't arrive in the App: "projects/projectId/messages/7043580007032901484"

What am I missing?

bytefish commented 6 years ago

@allistoncarlos You are using the Data Property. You have to use the Notification Property for sending a Notification:

https://github.com/bytefish/FcmSharp/blob/bef4cac6d49e02ec091cf8923bf7ed800eb10466/FcmSharp/FcmSharp/Requests/Message.cs#L15

Then it will work correctly.

allistoncarlos commented 6 years ago

Thanks! It's fully working now :D

bytefish commented 6 years ago

Great! Thanks for the feedback.