I am sending English
texts to iPhone Push notifications
upto 140 characters
long, however whenever I try same in Arabic language
it doesn't allow more longer than 35-40 chars
only.
Now, when I check the size, using strlen()
function and utf8_encode
it actually shows me of size about 190 bytes
and the total payload limit allowed by iPhone is 256 bytes
only.
Below is the Arabic text which I want to send:
يبدا بقرص العقيلي واللقيمات وينتهي مع خالد حرية بالامارات نكهة وبهار مع القصار-٦ مساءا على تلفزيون الكويت
It could be little longer, but Is there any solution using which I can send Apple iPhone Push notifications?
Do I needs to change/encode it to some special characters except json format
, which allows apple to read it properly and allow me sending.
Please help me achieve the same.
Thanks in advance.
My Code for Push Notifications, something like this:
$deviceToken = '**********************';
$payload['aps'] = array('alert' => 'My Arabic text', 'badge' => 1, 'sound' => 'default');
$payload = json_encode($payload);
$passphrase = '***';
$apnsHost = 'gateway.sandbox.push.apple.com'; $apnsPort = 2195; $apnsCert = 'ck.pem';
$streamContext = stream_context_create(); stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
stream_context_set_option($streamContext, 'ssl', 'passphrase',$passphrase );
$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
$apnsMessage = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
$result=fwrite($apns, $apnsMessage);
fclose($apns);