immobiliare / ApnsPHP

ApnsPHP: Apple Push Notification & Feedback Provider
BSD 3-Clause "New" or "Revised" License
1.44k stars 452 forks source link

Amazing and Clean Code. Need your help #115

Open samermg opened 8 years ago

samermg commented 8 years ago

Thank you for helping us. I never seen a clean code like this,

Im new to PHP, i followed the steps and got the following error while using push_simple_custom.php

//My configuration

// Instanciate a new ApnsPHP_Push object $push = new ApnsPHP_Push( ApnsPHP_Abstract::ENVIRONMENT_SANDBOX, 'ck_dev.pem' );

// Set the Root Certificate Autority to verify the Apple remote peer $push->setRootCertificationAuthority('ck_dev.pem');

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

// Instantiate a new Message with a single recipient $message = new ApnsPHP_Message_Custom('32e42c9c903d11d2ddb3da3d5296adc51a7a2ea541d04c253bf7fd29fde627d9');

Error

Mon, 18 Jan 2016 20:25:04 +0100 ApnsPHP[1868]: INFO: Trying ssl://gateway.sandbox.push.apple.com:2195... Mon, 18 Jan 2016 20:25:04 +0100 ApnsPHP[1868]: ERROR: Unable to connect to 'ssl://gateway.sandbox.push.apple.com:2195': (0) Mon, 18 Jan 2016 20:25:04 +0100 ApnsPHP[1868]: INFO: Retry to connect (1/1)... Mon, 18 Jan 2016 20:25:05 +0100 ApnsPHP[1868]: INFO: Trying ssl://gateway.sandbox.push.apple.com:2195... Mon, 18 Jan 2016 20:25:05 +0100 ApnsPHP[1868]: ERROR: Unable to connect to 'ssl://gateway.sandbox.push.apple.com:2195': (0) Fatal error: Uncaught exception 'ApnsPHP_Exception' with message 'Unable to connect to 'ssl://gateway.sandbox.push.apple.com:2195': (0)' in /home/cwtappsc/public_html/WafeatPHP/ApnsPHP/Abstract.php:396 Stack trace: #0 /home/cwtappsc/public_html/WafeatPHP/ApnsPHP/Abstract.php(334): ApnsPHP_Abstract->_connect() #1 /home/cwtappsc/public_html/WafeatPHP/ApnsPHP/sample_push_custom.php(41): ApnsPHP_Abstract->connect() #2 {main} thrown in /home/cwtappsc/public_html/WafeatPHP/ApnsPHP/Abstract.php on line 396

gaboh20 commented 7 years ago

As of Jan 2017 I had this problem. Turns out APNs url changed. Try with api.development.push.apple.com:443 for development and api.push.apple.com:443 for production. That worked for me.