0

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);
Parag Chauhan
  • 35,760
  • 13
  • 86
  • 95
  • Please include your server code in the question. It would be especially useful if you include the JSON you are trying to send. And you should check the length after converting the JSON string to bytes. – Eran Jul 19 '13 at 14:04
  • please see above, I have added actual code with json_encode which I am using at present – Parag Chauhan Jul 19 '13 at 14:47
  • Is [this question](http://stackoverflow.com/questions/17747510/php-ios-push-notifications-arabic-multilingual-text-larger-in-size) related to you? It's the same Arabic text, and the OP there says the payload is 360 bytes. – Eran Jul 19 '13 at 15:23
  • I ask my friend as well, may be he posted same in php.. – Parag Chauhan Jul 19 '13 at 16:24

0 Answers0