I'm trying to send Push Notifications to APN with tokenization. I tried to use a few libraries like jose-jwt and Microsot Jwt class for creating JWT token, but I can't wrap my head around it.
I get stuck on creating JWT and signing it with private key.
For communicating with certificates, I used PushSharp and it worked just fine. Can anyone help me with a working similar example but with tokens?
edit: following Apple's documentation here: https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1
Sample code: the closest I came to something would look like this, but I don't know how to create CngKey properly
var payload = new Dictionary<string, object>()
{
{ "iss", issuer },
{ "iat", DateTime.UtcNow }
};
var headers = new Dictionary<string, object>()
{
{ "kid", keyIdentifier}
};
CngKey key = CngKey.Create(CngAlgorithm.ECDsaP256); //how to create this CngKey
string token = Jose.JWT.Encode(payload, key, JwsAlgorithm.ES256, headers);