RobotsAndPencils / buford

A push notification delivery engine for the new HTTP/2 APNS service.
MIT License
475 stars 52 forks source link

the Topic header of the request was not specified and was required #91

Open ghost opened 7 years ago

ghost commented 7 years ago

my code works with the development certificate. But when I try and use the production certificate it gives me 'the Topic header of the request was not specified and was required' I did change host from push.Development to push.Production but it doesn't work. I also made sure that my .p12 file is made using both the cert and key.

yuanlida commented 7 years ago

I met the same problem.

kmcrawford commented 7 years ago

I was able to fix by using the app id set as a header:

headers := push.Headers{Topic: appId} //"com.myapp.app"
id, err := service.Push(token, &headers, b)
froodian commented 7 years ago

you can also generally use certificate.TopicFromCert to get this bundle id if you don't have it on hand.

yuanlida commented 7 years ago

Thanks,I add these codes in file service.go: req.Header.Set("Content-Type", "application/json") req.Header.Set("apns-topic", ".......") headers.set(req.Header)

nathany commented 7 years ago

It would be a good idea to document TopicFromCert in the README.