2

I am using Apns-PHP for sending push notification to IOS devices, below is the link of open source code which I have applied.

http://code.google.com/p/apns-php

It is working fine for English text messages however, for Hebrew text message sometimes its send null as text message. To overcome with it, I have applied solution suggested by the following link.

https://stackoverflow.com/a/10936493/1928421

As per the above link I have replaced my payload function with the given method, now I some text message is coming in push message but it seems like they are formatted with UTF8.

Here is the actual Hebrew text that I am passing to Apns.

"האילנית לזון זקוק לעזרה כדי לקחת מ גבעה ל ת"

And this the dictionary which is getting created by the script.

[aps] => Array (
  [alert] => Array (
    [body] => "\u05d4\u05d0\u05d9\u05dc\u05e0\u05d9\u05ea \u05dc\u05d6\u05d5\u05df \u05d6\u05e7\u05d5\u05e7 \u05dc\u05e2\u05d6\u05e8\u05d4 \u05db\u05d3\u05d9 " 
  ) 
  [badge] => 3
)

on device hand for the alert key I am receiving following text only.

"\u05d4\u05d0\u05d9\u05dc\u05e0\u05d9\u05ea \u05dc\u05d6\u05d5\u05df \u05d6\u05e7\u05d5\u05e7 \u05dc\u05e2\u05d6\u05e8\u05d4 \u05db\u05d3\u05d9 "

Any comment or suggestion is highly appreciated.

Community
  • 1
  • 1
Himanshu Ingole
  • 55
  • 2
  • 11
  • Thanks for replying. I have modified my question, let me know if anything else you need to know from my side. – Himanshu Ingole Feb 12 '13 at 10:01
  • Well, I don't know what the PHP code does, since I don't know PHP. However, the JSON you are sending doesn't seem right. I have a Java APN server, and when encoding the payload to UTF8 I encode the entire payload (the entire JSON String), not just the alert body. In addition, since you have a simple alert, you don't need to use the complex alert structure. It is enough to use [alert] => "some text". Finally, as a Hebrew speaker, the text you are trying to send doesn't make much sense to me. – Eran Feb 12 '13 at 13:31
  • Thanks Eran, the Hebrew text which you seeing is sample not the actual one string and apart from alert we are also sending few custom property. If you have observered the second link in the question I replaced my getpayload method with the given solution and we are converting the complete json into UTF8 – Himanshu Ingole Feb 12 '13 at 19:32
  • From what you posted it seems that you put in the alert body a String of the form "\u05d4\u05d0\u05d9..." and you encode that String when you encode the entire JSON into UTF8. So of course you would get exact String on the device. Before you encode the JSON to bytes the alert body String should contain the Hebrew text. – Eran Feb 12 '13 at 20:05
  • here is the actual json encoded or utf-8 encode string which we are sending to apns for push notification **{"aps":{"alert":"\u05d4\u05d0\u05d9\u05dc\u05e0\u05d9\u05ea \u05dc\u05d6\u05d5\u05df \u05d6\u05e7\u05d5\u05e7 \u05dc\u05e2\u05d6\u05e8\u05d4 \u05db\u05d3\u05d9 \u05dc\u05e7\u05d7\u05ea \u05de \u05d2\u05d1\u05e2\u05d4 \u05dc \u05ea\"\u05d0","badge":1,"sound":"default"},"server":{"serverId":null,"name":null}}** – Himanshu Ingole Feb 14 '13 at 16:16

1 Answers1

0

I have just downloaded the latest code from ** https://github.com/duccio/ApnsPHP/ ** and its works absolutely fine

Himanshu Ingole
  • 55
  • 2
  • 11