我在 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() 我可以手动传递令牌只是为了尝试吗?有没有人经历过这个或者我在哪里犯了错误?
SMILET
相关分类