php - APNS notification using API is not working -
i tried executing api apns using curl . code below
$pem_file = 'public/assets/pem/test.pem'; $pem_secret = ''; $apns_topic = 'com.test.demo'; if(defined('curl_http_version_2_0')) { $devicetoken=['54688ae0e1ecc3bc0d517521f4935c014342ecca792ef798f0e63652a4620ed4','de963dfbc03f5de416c7d806e04a6f3276716f246942fa2a61cffa393a780120','a08832de8b72567aa487beefe50e4e29caaa4a51ab14706fc8f0ef9df1f6b9c4','48335901c12bf02a03cef453d2e7739eaac9779991cafef3fa70ffe587ea3f12']; $sample_alert = '{"aps":{"alert":"hi","sound":"default"}}'; foreach($devicetoken $device_token) { $url = "https://api.development.push.apple.com/3/device/$device_token"; $ch = curl_init($url); curl_setopt($ch, curlopt_postfields, $sample_alert); curl_setopt($ch, curlopt_http_version, curl_http_version_2_0); curl_setopt($ch, curlopt_httpheader, array("apns-topic: $apns_topic")); curl_setopt($ch, curlopt_sslcert, $pem_file); curl_setopt($ch, curlopt_sslcertpasswd, $pem_secret); $response = curl_exec($ch); $httpcode = curl_getinfo($ch, curlinfo_http_code); //on successful response should true in response , status code of 200 var_dump($response);echo "----";var_dump($httpcode); } } else{ echo"not supported version"; } iam getting result :
�@@uunexpected http/1.x request: post /3/device/54688ae0e1ecc3bc0d517521f4935c014342ecca792ef798f0e63652a4620ed4 bool(true) ----int(0) i trying method handle invalid device token .earlier tried ssl using php link(http://learn-php-by-example.blogspot.in/2013/01/working-with-apple-push-notification.html) , in when invalid device token in db , when pass through loop push notification stops working . trying api method .
thanks in advance response guys
for new http/2 apns provider api, can use curl send push notifications : new apns provider api , php
Comments
Post a Comment