tiagomtotti / firebaseNet

Client library for Firebase Cloud Messaging (FCM) written in C# / .NET
Apache License 2.0
95 stars 30 forks source link

The execution stops on 'client.SendMessageAsync(message)' #17

Open diegosiao opened 6 years ago

diegosiao commented 6 years ago

Hi! I am trying to use this package on a Web Api project and the message is never sent.

In fact, when forcing the method to run synchronously, the .Result never gets a reference and the execution stops.

The referred block of code below:

                        var client = new FCMClient(AppConfig.GoogleFirebaseApiKey);
                        var message = new Message()
                        {
                            To = destination_user.FirebaseToken,
                            Notification = new AndroidNotification()
                            {
                                Body = mensagem,
                                Title = fromUser.Email,
                                Icon = "MyAppIcon"
                            }
                        };

                        var r = await client.SendMessageAsync(message);

Thanks in advance for any help.

jeanpaulmars commented 6 years ago

Same issue here. When using fiddler I see that the message is correctly send to google. (fcm.googleapis.com) and that the response is a 200. But then the execution ends and execution stops.

4straction commented 5 years ago

https://blogs.msdn.microsoft.com/jpsanders/2017/08/28/asp-net-do-not-use-task-result-in-main-context/

I changed to lambda function and it started to work