I want to send a push notification with a custom sound, but always I try, I hear only the default message.
my sound is called wil.caf and I have it in my xcode project.
this is my php sript to trigger a push message:
<?php
$message = $_GET["message"];
$deviceToken = $_GET["token"];
$devideToken = dechex ($deviceToken);
$payload['aps'] = array('alert' => $message, 'badge' => 0, 'sound' => 'default');
$payload = json_encode($payload);
$apnsHost = 'gateway.push.apple.com';
$apnsPort = 2195;
$apnsCert = 'apsDevBundle2.pem';
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
if ($apns)
{
$apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)).$payload;
fwrite($apns, $apnsMessage);
fclose($apns);
}
else
{
echo "Fehler!";
var_dump($error);
var_dump($errorString);
}
?>
Can anybody help me?
source
share