zendframework / ZendService_Apple_Apns

BSD 3-Clause "New" or "Revised" License
49 stars 69 forks source link

UTF8 payloads containing diacritics are broken #7

Closed dcelasun closed 10 years ago

dcelasun commented 11 years ago

In Message.php line 303 the existence of JSON_UNESCAPED_UNICODE results in messages not being delivered to the device if the payload contains diacritics.

I've used the message çşiğüı as payload and removing JSON_UNESCAPED_UNICODE bit seems to fix the problem.

This is probably not the ideal fix as I didn't investigate any further after removing that part.

asapo commented 11 years ago

I think this probrem caused by wrong $length of payload. It used mb_strlen but it returns UTF-8 char count, so it should use strlen for byte length.

We need JSON_UNESCAPED_UNICODE, because it being able to send more message.

strlen('çşiğüı') = 11 strlen('\u00e7Ÿi\u011f\u00fc\u0131') = 26

dcelasun commented 11 years ago

I think this probrem caused by wrong $length of payload.

Yep, looks like it.

We need JSON_UNESCAPED_UNICODE, because it being able to send more message.

How so? Do you have any examples?

asapo commented 11 years ago

How so? Do you have any examples?

Because payload can contain 256bytes. Not characters.

https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW4

Payload
variable length, less than or equal to 256 bytes

dcelasun commented 11 years ago

I see. So, changing mb_strlen to strlen should be enough?

asapo commented 11 years ago

Probably. But I want to hear the opinions of other people.

kwn commented 11 years ago

+1 fix with strlen

mwillbanks commented 10 years ago

Yes; this is indeed so that we can send longer messages when it is supported. I can update the unit test at some point here soon so that we can get this merged in. My apologies as I ahve been inactive for the last month.

dcelasun commented 10 years ago

@mwillbanks It's been 4 months, so any updates on this?