Search code examples
apple-push-notificationsapns-php

ApnsPHP Feedback Error


I am in trouble with APNS Feedback Service. I can send push notification but can't get inactive device tokens. I've read about pem file, they say it should be without password. And my pem file doesn't have password.

This is my sample_feedback.php file

<?php

// Adjust to your timezone
date_default_timezone_set('Europe/Istanbul');

// Report all PHP errors
error_reporting(-1);

// Using Autoload all classes are loaded on-demand
require_once 'ApnsPHP/Autoload.php';

// Instanciate a new ApnsPHP_Feedback object
$feedback = new ApnsPHP_Feedback(
    ApnsPHP_Abstract::ENVIRONMENT_PRODUCTION,
    dirname(__FILE__).'/pemfile.pem'
);

// Connect to the Apple Push Notification Feedback Service
$feedback->connect();

$aDeviceTokens = $feedback->receive();
print_r($aDeviceTokens);
if (!empty($aDeviceTokens)) {
    var_dump($aDeviceTokens);
}

// Disconnect from the Apple Push Notification Feedback Service
$feedback->disconnect();

And this is the error which I get

Fatal error: Uncaught exception 'ApnsPHP_Exception' with message 'Unable to connect to        'ssl://feedback.push.apple.com:2196': Connection refused (111)' in /ApnsPHP/Abstract.php:396 Stack trace: #0 ApnsPHP/Abstract.php(334): ApnsPHP_Abstract->_connect() #1 /sample_feedback.php(40): ApnsPHP_Abstract->connect() #2 {main} thrown in /ApnsPHP/Abstract.php on line 396

Thank you and sorry for bad English, I am not a native speaker.


Solution

  • If your pem file works for the push notifications, it should work for the Feedback service too. Please check that your server doesn't block port 2196.