I'm having a weird issue with Amazon AWS SNS : When creating subscriptions and topics using aws-php-sdk
(3.112.7), there is always a "ghost" or "invisible" subscription.
As you can see, this subscription exists in "subscriptions" tab. However, when I click on the topic link (here cav_56826
), I can't see any subscription.
Do you guys already had a similar issue ? How can this happen ?
Here is a my simplified code :
try
{
$arn = "arn:aws:sns:eu-west-1:XXXXXXXXXXXXXXXXX:app/APNS_VOIP_SANDBOX/ios_cav";
$topics = array("allUsers", "cav_56826");
$topicsToSubcribe = array();
foreach ($topics as $topic)
{
$res = $this->snsClient->createTopic(['Name' => $topic]);
if ($res->get('@metadata')['statusCode'] == 200)
{
array_push($topicsToSubcribe, $res->get('TopicArn'));
}
else
{
throw new Exception("An error occured during Amazon SNS createTopic", $res->get('@metadata')['statusCode']);
}
}
$SNSEndPointData = $this->snsClient->createPlatformEndpoint([
'PlatformApplicationArn' => $arn,
'Token' => $token
]);
foreach ($topicsToSubcribe as $topic)
{
$this->snsClient->subscribe([
'Protocol' => "application",
'Endpoint' => $SNSEndPointData->get('EndpointArn'),
'TopicArn' => $topic
]);
}
}
catch (\Exception $e)
{
// Logs some errors
}