Search code examples
c#apple-push-notificationspushsharpmoonapns

Push Notification using C# Push Sharp library is not working on production server


After certificate is generated, I've only exported the private key (without the certificate) in Keychain access, exported as .p12 and used the file, and it was not worked. I've exported only certificate and exported as .p12 and used the file, and it was also not worked.

The exception is:

You have selected the Production server, yet your Certificate does not appear to be the Production certificate! Please check to ensure you have the correct certificate!

If i use the same .p12 with MoonAPNS library it is working fine, but not with PUSHSHarp library. am using push sharp only for silent notifications.


Solution

  • Apple introduced a new unified Push Notification certificate that is valid for both Sandbox and Production servers. This new certificate has a bit different of a Subject Name (it used to contain either Apple Production IOS Push Services or Apple Development IOS Push Services and now it contains Apple Push Services).

    PushSharp 2.x does not know about this new format and still expects the old Subject Names to verify against, so it thinks your certificate is invalid.

    PushSharp 3.x (currently pre-release available on NuGet) is recommended and does properly validate the new type of certificate. I'd recommend updating to a 3.x version (of course there are some breaking API changes involved in that).

    If you are still insistent on using PushSharp 2.x, you can override the certificate validation by setting the disableCertificateCheck parameter to true in the ApplePushChannelSettings class constructor.