Unable to send push notifications to IOS using php-apn -
hi have installed package php-apn on linux sending push notifications ios , error is:
"unable use specified private key"
i tried using stream_socket_client , got similar error. path key/cert correct, have regenerated keys/certs again same outcome
the code below
// apns contex $apn = apn_init(); apn_set_array($apn, array( 'certificate' => '/var/www/html/scripts/certs/pushchatcert.pem', 'private_key' => '/var/www/html/scripts/certs/apns_cert.pem', // 'private_key_pass' => '', 'mode' => apn_production )); //apn_sandbox // notification payload context $payload = apn_payload_init(); apn_payload_set_array($payload, array( 'body' => 'push ', 'sound' => 'default', 'badge' => 1, 'tokens' => array ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ) )); apn_payload_add_custom_property($payload, 'test', 56); $error = null; $errcode = 0; // opening apple push notification service connection... if(apn_connect($apn, $error, $errcode)) { // , if ok, try send push notification.... if(!apn_send($apn, $payload, $error, $errcode)) { echo 'could not sent push notification: ' . $error; } } else { echo 'could not connected apple push notification service: ' . $error; } apn_close($apn); apn_payload_free($payload); apn_free($apn);
Comments
Post a Comment