alexalok / dotAPNS

dotAPNS is a library used to send push notifications to Apple devices using Apple Push Notification service via HTTP/2 API.
Apache License 2.0
114 stars 34 forks source link

Getting "MissingProviderToken" issue (.Net framework 4.6 with p12 certificate) #118

Closed rkbsoftsolutions closed 1 year ago

rkbsoftsolutions commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

Code snippet string certificatePath = HttpContext.Current.Server.MapPath("~/Certificates/23456789.p12"); X509Certificate2 cert = new X509Certificate2(System.IO.File.ReadAllBytes(certificatePath), "123456789", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable); var apns = ApnsClient.CreateUsingCustomHttpClient(new HttpClient(new WinHttpHandler()), cert); var push = new ApplePush(ApplePushType.Alert) .AddAlert("pn", "pn", text).AddToken(deviceToken);

        try
        {
            var response = await apns.SendAsync(push);

Expected behavior Call should be success.

Actual behavior getting "MissingProviderToken" issue

Environment dotAPNS version: (i.e. 4.0.1)

Additional context Add any other context about the problem here.

rkbsoftsolutions commented 1 year ago

I found the issue. As mentioned on documentation. Certificate validate not working with .Net framework. So I will have to upgrade the application and shifted to .Net core. 3.1 or above then I was working.