i have logged in two devices with same user id and password, so when destination device send voice or image to client .The one device getting the destination message but another one device not getting the destination message . because the resource id is getting change when login in two devices. Its showing error message 503()
(NSString *)full
{
if (user)
{
if (resource)
{
//----- here i am getting the resource ID -------
[[NSUserDefaults standardUserDefaults]setObject:resource forKey:@"GETRESOURCE"];
[[NSUserDefaults standardUserDefaults]synchronize];
return [NSString stringWithFormat:@"%@@%@/%@", user, domain, resource];
}
else
{
return [NSString stringWithFormat:@"%@@%@", user, domain];
}
} else {
if (resource)
return [NSString stringWithFormat:@"%@/%@", domain, resource];
else
return domain;
}
}
(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
CGFloat maxCompression = 0.1f;
NSData *imageData = UIImageJPEGRepresentation([info objectForKey:UIImagePickerControllerOriginalImage], maxCompression);
[messageType addObject:@"1"];
//---- now implementing the resource id here i getting 503 Error----
NSString *resourceStr = [[NSUserDefaults standardUserDefaults] valueForKey:@"GETRESOURCE"];
XMPPJID *jid = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@/%@", receiver, resourceStr]];
[fileTransfer initiateFileTransferTo:jid withData:imageData];
self.willSendImage = [UIImage imageWithData:imageData];
[messageArray addObject:[NSDictionary dictionaryWithObject:self.willSendImage forKey:@"image"]];
[self.timestamps addObject:[NSDate date]];
NSDate *currDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss Z"];
NSString *dateString = [dateFormatter stringFromDate:currDate];
[dbHandler insertChatHistory:@"image" imageData:imageData receiveType:2 mediaType:2 receiverName:titleName date:dateString];
[self finishSend];
[JSMessageSoundEffect playMessageSentSound];
[self scrollToBottomAnimated:YES];
[self reloadMessages];
[self dismissViewControllerAnimated:YES completion:NULL];
}
//--- I WILL SEND THE IMAGE AS A STRING FORMET ITS WORKED FOR ME
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
CGFloat maxCompression = 0.1f;
UIImage * getimage =[self imageWithImage:[info objectForKey:UIImagePickerControllerOriginalImage]];
NSData *imageData = UIImageJPEGRepresentation(getimage, maxCompression);
NSDate *currDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss Z"];
NSString *dateString = [dateFormatter stringFromDate:currDate];
//--- convert image to string -----
NSString* imageString = [imageData base64EncodedStringWithOptions:0];
//---- new change --
imageString = [imageString stringByAppendingString:@".IMAGE"];
//-------------
if ([imageString length] > 0)
{
[dbHandler insertChatHistory:imageString imageData:nil receiveType:2 mediaType:1 receiverName:titleName date:dateString];
NSXMLElement *body = [NSXMLElement elementWithName:@"body"];
[body setStringValue:imageString];
NSXMLElement *message = [NSXMLElement elementWithName:@"message"];
[message addAttributeWithName:@"type" stringValue:@"chat"];
[message addAttributeWithName:@"to" stringValue:receiver];
[message addChild:body];
[self.xmppStream sendElement:message];
[messageType addObject:@"1"];
[messageArray addObject:[NSDictionary dictionaryWithObject:imageString forKey:@"Text"]];
[self.timestamps addObject:[NSDate date]];
}
[self finishSend];
[JSMessageSoundEffect playMessageSentSound];
[self scrollToBottomAnimated:YES];
[self reloadMessages];
[self dismissViewControllerAnimated:YES completion:NULL];
}