Reputation: 36484
I have an iOS app that requires Push capability and to that end have created necessary dev and Prod SSL certs and loaded them on the notification provider(node-apn);
Notifications work fine in the APNs sandbox environment however, when sending notifications on the Production setup, the provider is getting missing topics error from APNs gateway.
Upon inspecting the prod certs, I see three items listed under certificate extensions as expected :
APSd logs on the phone, show that relevant topic (app.bundle.id) was enabled when the app registered its notification settings with the OS. So, the setup looks fine to me on the app side.
According to Apple documentation, the notification publish POST from Provider MUST include an apn-topic
header iff, the app supports multiple topics.
My understanding is that voip and complication nodes are added automatically to certificate extensions and do not necessarily mean separate topics.
Questions :
Is apn-topic header mandatory or optional?
Is the above setup treated as multi-topic or single topic?
Does every notification provider need to know bundle ID/topic for each app it supports and use that value to send apn-topic header to APNs?
Kindly advise.
Upvotes: 2
Views: 3128
Reputation: 36484
With Legacy certificates, developers got one certificate for each type of capability their app supported : regular PUSH notifications, VoIP etc. Each of these were configured with just one topic and therefore when the Notification provider interfaced with APNs gateway using legacy cert, specification of topic was optional.
With the new http2 interface and introduction of Universal certs, developers can now obtain one certificate that allows standard push, VoIP push and watchkit notifications if they desire so. Which means that the same cert can have more than one topic (as was my case). Therefore when the notification provider interfaced with APNs gateway using the new Universal certificate, topic had to be specified in http header and the topic needed to match one present in certificate.
Topic header is no longer optional.
Upvotes: 1
Reputation: 101
i had a similar problem between dev and prod, in my case the issue it was in the headers, related to the docs says:
The appropriate encoding to employ for the apns-id, apns-expiration, and apns-collapse-id request headers differs depending on whether it is part of the initial or a subsequent POST operation, as follows: The first time you send these headers, encode them with incremental indexing to allow the header names to be added to the dynamic table Subsequent times you send these headers, encode them as literal header fields without indexing
so in PHP the headers of the request go like this:
$headers[] = 'content-length: ' . strlen($data);
$headers[] = 'apns-topic: ' . $message->topic;
$headers[] = 'apns-expiration: ' . ($message->time_to_live ? (int)$message->time_to_live + time() : 0);
without the names or keys.
I hope it helps someone
Upvotes: 1