buford icon indicating copy to clipboard operation
buford copied to clipboard

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

Open ghost opened this issue 7 years ago • 5 comments

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.

ghost avatar Aug 28 '17 20:08 ghost

I met the same problem.

yuanlida avatar Nov 08 '17 06:11 yuanlida

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)

kmcrawford avatar Nov 15 '17 21:11 kmcrawford

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

froodian avatar Nov 16 '17 00:11 froodian

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)

yuanlida avatar Nov 16 '17 01:11 yuanlida

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

nathany avatar Nov 17 '17 05:11 nathany