我收到 APNs 的 MissingProviderToken 错误

我在 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)


这个token需要证书传递吗?


我尝试了我公司创建的两个不同的证书,但仍然返回 403 MissingProviderToken。我也试过 client := apns2.NewClient(cert).Development()  我可以手动传递令牌只是为了尝试吗?有没有人经历过这个或者我在哪里犯了错误?


BIG阳
浏览 768回答 1
1回答

SMILET

从本指南Local and Remote Notification Programming Guide: Communicating with APNs 开始,这意味着 No provider certificate was used to connect to APNs and Authorization header was missing or no provider token was specified。所以,更改证书。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go