<?php
sendIosTechPush("test", "testing", "fa0b4a8e c7405260 4d89f4c0 a0544485 414f7382 a34c0329 8bf0d101 643b1b52", "tech");
function sendIosTechPush($title, $body, $token, $show_in) {
	
	// Put your device token here (without spaces):
	
	$deviceToken = str_replace(" ", "", $token);
	// Put your private key's passphrase here:
	$passphrase = 'swaroop';
	//// Put your alert message here:
	$message = $title." - ".$body;

	$ctx = stream_context_create();
	//stream_context_set_option($ctx, 'ssl', 'local_cert', 'ckT.pem');
	stream_context_set_option($ctx, 'ssl', 'local_cert', 'CKPdtnTech.pem');	
	stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

	$fp = stream_socket_client('ssl://gateway.push.apple.com:2195',
							   $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);	

	// Create the payload body
	$push_body['aps'] = array('badge' => +1, 'alert' => $message, 'sound' => 'default');
	$payload = json_encode($push_body);

	// Build the binary notification
	$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
	// Send it to the server
	$result = fwrite($fp, $msg, strlen($msg));
	
	if (!$result) {
    	echo 'Message not delivered' . PHP_EOL;
	} else {
    	echo 'Message successfully delivered amar'.$message. PHP_EOL;
	}
	// Close the connection to the server
	fclose($fp);
}
?>