Closed zoharshavit closed 6 years ago
Anyone?
Dont know og you have solved this one, but it wont hang if you use the async method
Thank you @Ullvar,
I solved my issue by executing the send in a different thread.
So now, my code looks like this:
Thread t = new Thread((a) => { try { webPushClient.SendNotification((WebPush.PushSubscription)a, Newtonsoft.Json.JsonConvert.SerializeObject(msg, Newtonsoft.Json.Formatting.None)); } catch (WebPushException exception) { Console.WriteLine("Http STATUS code" + exception.StatusCode); } catch (Exception e) { } }); var s = new WebPush.PushSubscription(endpoint, p256dh, auth); t.Start(s);
The thing I don't understand is why the sync method did not return even though it sent the msg.
Great! I dont know but it could be that beacuse javascript is async and scince this solution is ported from a js solution it fails beacuse c# thinks that it is a sync method.
Hi, Whenever my server executes the SendNotification method it hangs and not returning from it. The notification, however, is successfully recived on client's service worker. This is my code:
Any ideas? Since I do get the notification, I think my code is fine, but.... Thanks