Search code examples
phpiosswiftpushapn

iOS APN Php Cannot Connect


I followed this youtube tutorial on how to send push notifications: https://www.youtube.com/watch?v=_3YlqWWnI6s

When I run the php file on my webserver however it times out giving me this error. I have looked at the web and nothing I could find seems to be the problem, can someone suggest where I have gone wrong..

[14-Dec-2015 06:13:10 America/New_York] PHP Warning:  stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection timed out) in /home2/sptechno/public_html/Wink/sendPush.php on line 18

Solution

  • when you run .php file for Apple push notification.

    That time you need to check the TCP/UDP Port number is open on your server other wise notification not pass to apple server.

    General Provider Requirements

    As a provider you communicate with Apple Push Notification service over a binary interface. This interface is a high-speed, high-capacity interface for providers; it uses a streaming TCP socket design in conjunction with binary content. The binary interface is asynchronous.

    The binary interface of the production environment is available through gateway.push.apple.com, port 2195; the binary interface of the development environment is available through gateway.sandbox.push.apple.com, port 2195.

    Apple official document for that.

    EDITED

    Check for your server is connected to APNS.

    HOSTGATOR:~ Home$ telnet gateway.sandbox.push.apple.com 2195

    Trying 17.149.34.143...

    Connected to gateway.sandbox.push-apple.com.akadns.net.

    Escape character is '^]'.