0
votes

I need a little help in implementing push notification in iOS. I am using Swift.

I successfully created Push certificate and key (.pem). I am able to retrieve the deviceToken. And I was able to send notification to my device via APN Tester Free app. So, basically push notification is working in my local computer.

I found this tutorial and picked up the PHP file and uploaded it to the server, together with my .PEM file. But when I try to open sample.com/newspush.php, I get Service Unavailable.

I also tried other tutorial (I could not remember the link). But I am getting: Failed to connect to the APNS server. Error = Connection timed out

1

1 Answers

0
votes

This is because your server didn't allow access.Set up the permission wrong on the folder that had the certificate file. Give chmod 755 permission to that folder which contains .pem file. This will fix your problem.

Or may be your server closed the 2195 port. So make sure that port open.To check that can run this code in you server.

 telnet gateway.push.apple.com 2195

If your server has a problem it will show something like this :-

Trying 17.172.233.36...
telnet: connect to address 17.172.233.36: Connection refused

So then you solve this problem by opening the 2195 port

If your server already open the port it will show :-

 -bash-3.2# telnet gateway.push.apple.com 2195

  Trying 17.149.38.141...
  Connected to gateway.push.apple.com (17.149.38.141).
  Escape character is '^]'.
  Connection closed by foreign host.

Hope that this will help you!