0

我将English文本发送iPhone Push notifications到最长140 characters,但是每当我尝试相同时,Arabic language它只允许更长的时间35-40 chars

现在,当我使用strlen()函数检查大小时,utf8_encode它实际上向我显示了大约大小,190 bytes而 iPhone 允许的总有效负载限制256 bytes仅为。

以下是我要发送的阿拉伯语文本:

يبدا بقرص العقيلي واللقيمات وينتهي مع خالد حرية بالامارات نكهة وبهار مع اقصار-٦ اكويءا على تفزيون

它可能会更长一点,但是有什么解决方案可以用来发送 Apple iPhone 推送通知吗?

我是否需要将它更改/编码为一些特殊字符,除了json format,这允许苹果正确读取它并允许我发送。

请帮助我实现同样的目标。

提前致谢。

我的推送通知代码,如下所示:

$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);
4

0 回答 0