-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BalloonImage is missing when cell message contain Media #43
Comments
No, ballon image is there i check it while debugging. |
@WarisSaqi Hi did you find any solution I am also facing same issue please help me |
@bintu1234 i found the solution here is the detail there is a method setMessage in SOMessageCell.m i mistakenly commit the line [self setInitialSizes] after un-commiting it my issue is solved, check may be this can help you out too.
|
can you please paste some code where you are sending images. and then displaying the images in cell. so that i can help you out. |
[self.chatHistoryArray removeAllObjects];
[self refreshMessages]; This is my fetching method from sqlite and sending images here NSXMLElement *body = [NSXMLElement elementWithName:@"body"]; NSXMLElement *messageBody = [NSXMLElement elementWithName:@"message"]; if (SendImage) { |
sorry for my coding standards i am new to ios |
No issue for coding if (SendImage) {
|
@WarisSaqi Hi thanks for the replay actually what i am doing is when i send the image i will send it to server and from there i am getting image url so i am inserting that imageurl in sqlite as a string and have any sample code for chatting for somessaging i googled but no result please help me out |
@bintu1234 i check your code why are you using third party base 64 encoding as now apple sdk available for base64 encoding and decoding. And the other thing you are saving the url then why are you using the base64 encoding decoding direct use sdWebImage to show the image from url. |
@WarisSaqi Thanks for the replay I will try SDWebImage thanks for your suggestion and one more thing is when i am sending image all the above conversations are changed to images and showing blank even bubble image is there any problem with my conditions. |
@bintu1234 one more thing i noted in your account that you are closing your database right after the adding the object in your array while loop is still running and its calls every time till loop end why are you doing so and for sending image you are sending the base64 string to other user as image while you are saying that you sen the image to server and then send the url of image in chat. Its wrong use the same thing on both end base64 string or url which ever you prefer and save both in your db right after you send or receive the image and one more thing that add this receiving or sending image should be in your messages array before you refresh the SOMessaging tableview. |
@WarisSaqi Thanks for the advise and why base 64 means my client want some animation while sending and recieving images so i just feel that it is possible by base64 string so i just use the base64 and thanks for your valueble time based on your answers i think i am missing something inserting and retriving in sqlite any way thanks if any thing i miss can i ask you |
@bintu1234 yes sure anytime. |
@WarisSaqi I tried my level best for sending the images but i am unable to handle please help me out how you will send the messages in somessaging will you please share some code to sending text as well as image i am struggling from last 2 weeks please help me thanks in advance |
@bintu1234 Here is top overview of the Sending and receiving images using XMPP framework in SOMessaging. Sending: Get image from UIImagePickerController. Receiving: Receive image URL from user. Here is the code example - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
[picker dismissViewControllerAnimated:NO completion:^{
}];
UIImage* selectedImage = (UIImage*)[info objectForKey:UIImagePickerControllerOriginalImage];
if (!selectedImage) {
selectedImage = (UIImage*)[info objectForKey:UIImagePickerControllerEditedImage];
}
[SVProgressHUD showWithStatus:@"" maskType:SVProgressHUDMaskTypeBlack];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
[self performSelector:@selector(sendImage:) withObject:selectedImage afterDelay:1.0];
}
- (void)sendImage:(UIImage *)image{
NSString *myJID = // your Jabber id
XMPPJID *jid = // receipt Jabber id
//API Call to upload Picture on Tellmo Server
UIImage *compressedImage = [UIImage compressImage:image compressRatio:0.9f];
NSData *imageData = UIImageJPEGRepresentation(compressedImage, 1.0);
if (imageData != nil) {
NSDictionary *paramDict = //your API call perimeter to upload image on your own server
[SharedAPIManager callWebserviceForMethod:kAPI_UploadFile WithParam:paramDict withCompletionHandler:^(APIManager *response) {
if (response.data) {
// Settings Up Message To Send
NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
// Send XMPP Message
NSXMLElement *messageToSend = [NSXMLElement elementWithName:@"message"];
[messageToSend addAttributeWithName:@"type" stringValue:@"chat"];
[messageToSend addAttributeWithName:@"date" stringValue:[NSDate getStringFromDate:[NSDate date] withFormat:@"yyyy-dd-mm HH:MM:ss"]];
[messageToSend addAttributeWithName:@"to" stringValue:[jid full]];
[body setStringValue:response.data];
[messageToSend addChild:body];
[xmppStream sendElement:messageToSend];
}
}];
// Show in UI
Message *soMessage = [[Message alloc] init];
soMessage.fromMe = YES;
soMessage.date = [NSDate date];
soMessage.type = [self messageTypeFromString:MessageTypeImage];
soMessage.thumbnail = image;
soMessage.media = UIImageJPEGRepresentation(compressedImage, 1.0);
soMessage.text = @"Image";
[self saveMessageInDB:soMessage];
}
} Receiving Side: - (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message {
NSString *messageText = [[message elementForName:@"body"] stringValue];
NSString *messageSender = [[message attributeForName:@"from"] stringValue];
Message *soMessage = [[Message alloc] init];
soMessage.fromMe = NO;
soMessage.date = [NSDate date];
// id photoElement = [message elementForName:@"photo"];
if ([messageText rangeOfString:@"your server file location string"].location != NSNotFound) {
NSString *urlString = messageText;
soMessage.type = SOMessageTypePhoto;
soMessage.text = @"Image";
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
[[SDWebImageDownloader_Tellmo sharedDownloader] downloadImageWithURL:request.URL options:SDWebImageDownloaderContinueInBackground progress:^(NSUInteger receivedSize, long long expectedSize) {
} completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
if (finished) {
dispatch_async(dispatch_get_main_queue(), ^{
soMessage.thumbnail = [UIImage imageWithData:data];
soMessage.media = data;
[self saveIncomingMessage:message soMessage:soMessage messageSender:messageSender];
});
}
}];
}
else{
soMessage.type = SOMessageTypeText;
soMessage.text = messageText;
if (messageText) {
[self saveIncomingMessage:message soMessage:soMessage messageSender:messageSender];
}
}
} I am using XMPP framework to do all chatting stuff and KissXML for xml creating all stuff relating to XML. |
@WarisSaqi Thank you so much for the replay let me try |
@WarisSaqi Hi i don't want disturb you but i am unable to handle with the above code can you please help me how to handle images and text in somessaging please help me your are the last hope |
@bintu1234 , I am unable to understand that what is the thing you are unable to handle? |
@WarisSaqi yes but when i send image remaining all are showing as images even text also so thats why i am asking at sqlite end only we need to save the url of image right ? this is my fetching method from DB
|
@bintu1234 Yes you only need to save the url of image in Sqlite or NSData of Image. |
@WarisSaqi okay but while sending image we need to give the type as somessagphoto but it is not taking when i am fetching from DB it is showing as URL in chat can you please help me if you don't mine can you check my code if you want i will send my code |
@bintu1234 , i check your code your issue is in this following lines of code for (int i=0; i<[messageArray count]; i++) here you can see that you set type of every message to SOMessageTypeText. I Bold that particular line. |
@bintu1234 , I look your code i found something that may cause the issue the line i bold is the issue you have to check whether the message is text or photo if text then set type to SOMessageTypeText otherwise set the type to SOMessageTypePhoto |
@WarisSaqi i tried like you said but same result if possible check my entire project then it will be help full like life saver please |
@bintu1234 , ok mail me i will check it tomorrow. |
@WarisSaqi thank you so much please send me your mailId |
@bintu1234 , Go into your ASNMessageChat.m and replace your fetchFromDatabase method with this one
|
@WarisSaqi Thank you so much Sir really you saved me it's working now thank you |
@bintu1234 , you are welcome... |
@WarisSaqi if you don't mind can you please have a look on this issue #47 please. I tried but unable to get the solution. |
I am using SOMessagging in my app and its behaving very inconsistent when images and text is showing in same thread. Some times ballonImage is not shown in text as seen in pics. Its clearly seen that text and balloonImage both are not shown but they both exist there and options are appear. Tell me how could i handle it, thanks in advance.
The text was updated successfully, but these errors were encountered: