JSON encoding error for super long messages
This commit is contained in:
@@ -12,8 +12,10 @@
|
||||
|
||||
+ (instancetype)responseWithJSONObject:(id)object
|
||||
{
|
||||
NSData *data = [NSJSONSerialization dataWithJSONObject:object options:0 error:NULL];
|
||||
NSError *error = nil;
|
||||
NSData *data = [NSJSONSerialization dataWithJSONObject:object options:0 error:&error];
|
||||
if (data == nil) {
|
||||
NSLog(@"JSON encoding error: %@", error);
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
IMMessage *lastMessage = [self lastMessage];
|
||||
if (lastMessage) {
|
||||
chatDict[@"lastMessagePreview"] = [lastMessage descriptionForPurpose:IMMessageDescriptionConversationList];
|
||||
NSString *lastMessagePreview = [lastMessage descriptionForPurpose:IMMessageDescriptionConversationList];
|
||||
chatDict[@"lastMessagePreview"] = [lastMessagePreview substringToIndex:MIN(128, [lastMessagePreview length])];
|
||||
chatDict[@"lastMessage"] = [lastMessage mbim_dictionaryRepresentation];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user