0

I receive long size payload of NSString in body payload of push notification that I need to convert it to NSData and then save it in corredata. I am using the method:

dataUsingEncoding:NSUTF8StringEncoding

This works fine for short String but for long size string 2049 KB size, it seems convert half of my String to NSData not all... when I print the length of NSData it gives 1000, it seems the maximum size is 1000.... when I convert short String to NSData and print the size which around 677 works correctly.

Any idea?

Steven
  • 63
  • 5
  • Does this answer your question? [Convert NSData to NSString - NSLog limitation](https://stackoverflow.com/questions/41914815/convert-nsdata-to-nsstring-nslog-limitation) – pkamb Sep 10 '20 at 21:36
  • Is it just an issue of **printing** the string with NSLog? – pkamb Sep 10 '20 at 21:36
  • No, when I convert the NSData to NSString, I see only half of my string not all, when I print the length of NSData, it gives 1000, less then 1000 length works correctly. – Steven Sep 10 '20 at 21:44
  • There's more to this than the question covers. Converting strings to/from binary data doesn't cut like that. – Tom Harrington Sep 10 '20 at 22:00
  • Hi @ Tom Harrington any idea? – Steven Sep 10 '20 at 22:04
  • 1
    Please post the complete code of a [MCVE](https://stackoverflow.com/help/minimal-reproducible-example) of this occurring. – pkamb Sep 10 '20 at 22:24
  • @Steven Sorry if I wasn't clear. The idea was that you would provide more detail about your app and how it manages this data, so that maybe it would be possible to tell what was going wrong. – Tom Harrington Sep 11 '20 at 20:56

1 Answers1

0

I am going to answer here, it can help some one else in future.

The main problem it wasn’t the method, in debug the information was coming correctly in body parameter of push notification but when I was trying to getting the body like :

NSString* body = self.bestAttemptContent.body;

The main problem is here, when the string body is long size, it cut automatically and I didn’t find any documentation about it... however I added “data” parameter in payload of push notification and when I receive the push notification I get the string from data parameter and it gives correctly all the string.

Steven
  • 63
  • 5