我在使用APNs时遇到了MissingProviderToken错误。

huangapple go评论87阅读模式
英文:

I receive MissingProviderToken error with APNs

问题

我正在使用Golang通过APNs在iOS上发送带有证书的推送通知,但是我收到了MissingProviderToken错误。在调试代码时,我发现客户端的令牌为空。我使用了sideshow库,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)

这个令牌需要通过证书传递吗?

我尝试了两个由我的公司创建的不同证书,但仍然返回403 MissingProviderToken错误。
我还尝试了client := apns2.NewClient(cert).Development()
我可以手动传递令牌来尝试吗?
有人遇到过这个问题吗?我在哪里犯了一个错误?

英文:

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?

答案1

得分: 1

根据这个指南本地和远程通知编程指南:与APNs通信,它的意思是“没有使用提供者证书连接到APNs,授权头缺失或未指定提供者令牌”。

所以,请更换证书。

英文:

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.

huangapple
  • 本文由 发表于 2022年11月16日 19:17:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/74459553.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定