firebaseNet icon indicating copy to clipboard operation
firebaseNet copied to clipboard

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

Open diegosiao opened this issue 7 years ago • 2 comments

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.

diegosiao avatar Oct 24 '17 18:10 diegosiao

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.

jeanpaulmars avatar Mar 22 '18 07:03 jeanpaulmars

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

4straction avatar Jan 21 '19 17:01 4straction