PushSharp APNS production: The credentials supplied to the package were not recognized (development works fine though)

前端 未结 6 1474
小鲜肉
小鲜肉 2020-12-03 07:00

My app just got ready for sale on App Store, but none of my production devices (devices that have installed the app from App Store) are getting push notifications. When I tr

6条回答
  •  再見小時候
    2020-12-03 07:39

    "The credentials supplied to the package were not recognized" exception usually indicates that the user running the code does not having enough permissions.

    If you are sending push notifications from Azure web app or webjob do not load the APNS certificate from a file or base64-encoded string. Go to Azure Portal and add the certificate to website instead. Note the thumbprint.

    Next add WEBSITE_LOAD_CERTIFICATES setting and set it to * (asterisk).

    Now the APNS certificate can be used from C# code:

    string thumbprint = "YOUR THUMBPRINT";
    var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
    store.Open(OpenFlags.ReadOnly);
    var certificate = store.Certificates.Find(
        X509FindType.FindByThumbprint, thumbprint, validOnly: false)
        .Cast().SingleOrDefault();
    var apnsConfig = new ApnsConfiguration(
        ApnsConfiguration.ApnsServerEnvironment.Production, certificate);
    

    References

    • Using Certificates in Azure Websites Applications
    • Configuring a certificate for APNS on the Azure platform

提交回复
热议问题