Search code examples
iosgopush-notificationapple-push-notifications

I receive MissingProviderToken error with APNs


I am sending a push notification in Golang with a certificate on iOS via APNs and I receive MissingProviderToken error. Indeed, debugging the code, I see that the client has a null token. I use sideshow library, sideshow/apns2.

cert, err := certificate.FromP12File("./certificates.p12", "*filepassword*")

if err != nil {
   log.Fatal("Cert Error:", err)
}
notification := &apns2.Notification{}
notification.DeviceToken = *deviceToken*
notification.Topic = "*appbundleid*"
notification.Payload = []byte(`{
      "aps" : {
         "alert" : "Hello!"
      }
   }
`)

client := apns2.NewClient(cert).Production()
res, err := client.Push(notification)

Does this token need to be passed by the certificate?

I tried two different certificates created by my company but still returns 403 MissingProviderToken. I tried also client := apns2.NewClient(cert).Development() Can I manually pass token just to try? Did anyone experience this or where am I making a mistake?


Solution

  • From this guide Local and Remote Notification Programming Guide: Communicating with APNs, it means No provider certificate was used to connect to APNs and Authorization header was missing or no provider token was specified.

    So, change the certificate.