'c# how to send ios notification via dotAPNS (nuget package) / how to read a certificate in c#?
The below code is in my c# api project in the notification service. I am using the dotAPNS nuget package to enable ios notifications. However, when I try to send the request I get an error thrown which has to deal with the CertContent contents. I feel like I am not doing it correctly and the error reassures that doubt. Can you help me figure out what I am doing wrong?
var cer = HttpContext.Current.Server.MapPath("../../Security/distribution.cer");
var x509 = new X509Certificate2(File.ReadAllBytes(cer)).ToString();
var options = new ApnsJwtOptions()
{
BundleId = "bundleID",
CertContent = x509,
KeyId = "keyID",
TeamId = "teamID"
};
var apns = ApnsClient.CreateUsingJwt(new HttpClient(new WinHttpHandler()), options);
var push = new ApplePush(ApplePushType.Alert)
.AddAlert("title", model.UserName + ", commented on your post.")
.AddToken("deviceToken");
The below is the exception message I get when it gets to ApplePush:
The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
I thank you in advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
