Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FCM Net threw an error #24

Open
Chinajiyong opened this issue Dec 10, 2018 · 1 comment
Open

FCM Net threw an error #24

Chinajiyong opened this issue Dec 10, 2018 · 1 comment

Comments

@Chinajiyong
Copy link

Chinajiyong commented Dec 10, 2018

Following is my code:
public async Task SendPushNotification(string deviceToken, Notification notification, object data)
{
var serverKey = _configuration["FCMServerKey"];

        bool sent = false;

        if (!String.IsNullOrEmpty(deviceToken))
        {
            using (var sender = new Sender(serverKey))
            {
                var message = new Message
                {
                    To = deviceToken,
                    Priority = Priority.High,
                    ContentAvailable = true,
                    Notification = notification,
                    Data = data
                };

                var result = await sender.SendAsync(message);
                Console.WriteLine($"Success: {result.MessageResponse.Success}");

                sent = result.MessageResponse.Success == 1;
            }
        }

        return sent;
    }

And I got this error:

at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication1 application) 2018-12-10 15:12:17.6160|Default|0HLIUDJT5GOSP:00000007||Microsoft.AspNetCore.Server.Kestrel|ERROR|Connection id "0HLIUDJT5GOSP", Request id "0HLIUDJT5GOSP:00000007": An unhandled exception was thrown by the application. System.OperationCanceledException: The operation was canceled. at System.Net.Http.HttpClient.HandleFinishSendAsyncError(Exception e, CancellationTokenSource cts) at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at FCM.Net.Sender.SendAsync(HttpContent content)
at FCM.Net.Sender.SendAsync(Message message)
at Nova.Api.Tools.FCMPushNotification.SendPushNotification(String deviceToken, Notification notification, Object data) in E:\NovaGitProjects\Nurish\Nurish\SourceCode\Server\src\Nova.Pms.Modules\Nova.Api\Tools\FCM\FCMPushNotification.cs:line 81
at Nova.Api.Controllers.PlanController.RespondActivity(RespondRequestDto request) in E:\NovaGitProjects\Nurish\Nurish\SourceCode\Server\src\Nova.Pms.Modules\Nova.Api\Controllers\PlanController.cs:line 281

@Chinajiyong
Copy link
Author

@angelobelchior Could you please take a look at this error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant