2
votes

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.

1
Can you show us the JSON you are sending as payload and the code you use to encode the JSON String into bytes?Eran
Thanks for replying. I have modified my question, let me know if anything else you need to know from my side.Himanshu Ingole
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
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 UTF8Himanshu Ingole
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

1 Answers

0
votes

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