we have exactly the same problem when sending pushes to different team ids using the same connection. The steps to reproduce are:
-
Open a connection to APNS and use the same connection to:
-
Send a token based push to topic
com.companyA.xxx
of team id1234
: APNS accepts and delivers the push successfully. - Send a token based push to topic
io.companyB.xxx
of team id5678
: APNS respondsHTTP 400 BadRequest The device token does not match the specified topic
- Send again a token based push to topic
io.companyB.xxx
of team id5678
: APNS respondsHTTP 403 Forbidden: the provider token is not valid or the token signature could not be verified
.
After this it becomes impossible to send any push and the connection has to be closed and reopened.
The workaround we ended up doing is to open one connection per team id. The APNS documentation does not mention anything like that so I do consider this as a bug and I opened a bug report.