Closed KeyideasGlobal closed 10 years ago
XMPPvCardTempModule
has the following method that does what you want:
/**
* Fetches the vCardTemp for the given JID, optionally ignoring the storage
**/
- (void)fetchvCardTempForJID:(XMPPJID *)jid ignoreStorage:(BOOL)ignoreStorage;
Hi , and please tell me which api give all friends list and which one function save it in core data in obj c.
Thanks Mahendra
hi , Could you tell me how can i change profile picture in xmpp using obj c.
Thanks Mahendra
To set you Avatar you need to update your vCard:
XMPPvCardTemp *myVcardTemp = [xmppvCardTempModule myvCardTemp];
[myVcardTemp setPhoto:photo];
[xmppvCardTempModule updateMyvCardTemp:myVcardTemp];
Hi, Thanks for reply this card updating change my profile image in my database swell as server both or only in my database . i am using this method
-(IBAction)done_clicked:(id)sender
{
NSData *imageData1 = UIImageJPEGRepresentation(self.profileImageview.image,0.5);
NSLog(@"self.profileImageview.image...%@",self.profileImageview.image);
NSString *email_address=self.emailIdtestfield.text;
NSString *phone_number=self.phoneNotestfield.text;
NSString *org_name=self.schoolNametestfield.text;
NSArray *arr_phone=[NSArray arrayWithObjects:phone_number, nil];
NSArray *arr_email=[NSArray arrayWithObjects:email_address, nil];
NSXMLElement *vCardXML = [NSXMLElement elementWithName:@"vCard" xmlns: @"vcard-temp"];
NSXMLElement *photoXML = [NSXMLElement elementWithName:@"PHOTO"];
NSXMLElement *typeXML = [NSXMLElement elementWithName:@"TYPE" stringValue:@"image/jpeg"];
NSXMLElement *binvalXML = [NSXMLElement elementWithName:@"BINVAL"
stringValue:[imageData1 base64EncodedString]];
[photoXML addChild:[typeXML copy]];
[photoXML addChild:[binvalXML copy]];
[vCardXML addChild:[photoXML copy]];
[photoXML addChild:[typeXML copy]];
[photoXML addChild:[binvalXML copy]];
[vCardXML addChild:[photoXML copy]];
// id<OTRProtocol> protocol = [[OTRProtocolManager sharedInstance] protocolForAccount:appDelegate.userAccount];
XMPPvCardTemp *myvCardTemp = [[ appDelegate xmppvCardTempModule]
myvCardTemp];
// NSLog(@"myvCardTemp...%@",myvCardTemp.);
/* if (myvCardTemp)
{
[myvCardTemp setPhoto:imageData1];
[[ appDelegate xmppvCardTempModule] updateMyvCardTemp
:myvCardTemp];
}*/
//else
{
XMPPvCardTemp *newvCardTemp = [XMPPvCardTemp vCardTempFromElement :vCardXML];
// if (imageData1) {
// [newvCardTemp setLogo:imageData1];
// }
if([self.LastNametestfield.text length]>0)
[newvCardTemp setNickname:[NSString stringWithFormat:@"%@",self.LastNametestfield.text]];
NSLog(@"arr_phone %@",arr_phone);
if([arr_phone count]>0){
[newvCardTemp setTelecomsAddresses:arr_phone];
[newvCardTemp setMiddleName:[arr_phone objectAtIndex:0]];
}
if([arr_email count]>0){
[newvCardTemp setEmailAddresses:arr_email];
[newvCardTemp setFormattedName:[arr_email objectAtIndex:0]];
//[newvCardTemp setEMAILName:[arr_email objectAtIndex:0]];
}
if([org_name length]>0)
[newvCardTemp setOrgName:org_name];
NSLog(@"inside here...%@",vCardXML);
NSLog(@"self.firstNametestfield.text here...%@",self.LastNametestfield.text);
[[appDelegate xmppvCardTempModule] updateMyvCardTemp :newvCardTemp];
}
/*if ([self.firstNametestfield.text length]>0 &&[self.LastNametestfield.text length]>0)
{
XMPPvCardTemp *myvCardTemp = [[appDelegate xmppvCardTempModule] myvCardTemp];
if (!myvCardTemp)
{
NSLog(@"come here for name %@ %@",self.firstNametestfield.text,self.LastNametestfield.text);
NSXMLElement *vCardXML = [NSXMLElement elementWithName:@"vCard" xmlns:@"vcard-temp"];
XMPPvCardTemp *newvCardTemp = [XMPPvCardTemp vCardTempFromElement:vCardXML];
[newvCardTemp setNickname:[NSString stringWithFormat:@"%@ %@",self.firstNametestfield.text,self.LastNametestfield.text]];
// [newvCardTemp setName:@"Ansari"];
// [newvCardTemp setEmailAddresses:@"usmaanirfan@gmail.com"];
// [newvCardTemp setOrgName:<#(NSString *)#>
// [newvCardTemp setTelecomsAddresses:<#(NSArray *)#>
[[appDelegate xmppvCardTempModule] updateMyvCardTemp:newvCardTemp];
}
else
{
//Set Values as normal
}
}
if (imgChngSts==1)
{
[self picture_change:self.profileImageview.image];
}*/
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reachabilityChanged:)
name:kReachabilityChangedNotification
object:nil];
// Reachability * reachability = [Reachability reachabilityForInternetConnection];
// NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
// if(remoteHostStatus == NotReachable)
// {
// UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"No internet connection found.Please check or try again." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
// [alert show];
//
// }
//
// if(remoteHostStatus != NotReachable)
// {
// NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
// if ([self.LastNametestfield.text length]>0 && ![self.LastNametestfield.text isEqualToString:@"(null)"])
// {
// [userDefaults setValue: self.LastNametestfield.text forKey:@"nic_name"];
// }
//
// if ([self.schoolNametestfield.text length]>0 && ![self.schoolNametestfield.text isEqualToString:@"(null)"])
// {
// [userDefaults setValue: self.schoolNametestfield.text forKey:@"org_name"];
// }
//
// if ([self.phoneNotestfield.text length]>0 && ![self.phoneNotestfield.text isEqualToString:@"(null)"])
// {
// [userDefaults setValue: self.phoneNotestfield.text forKey:@"tel_num"];
// }
//
// if ([self.emailIdtestfield.text length]>0 && ![self.emailIdtestfield.text isEqualToString:@"(null)"])
// {
// [userDefaults setValue: self.emailIdtestfield.text forKey:@"mail_id"];
// }
// [userDefaults synchronize];
//
// }
[self called_ProfileData];
[self dismissViewControllerAnimated:YES completion:nil];
}
but its not give response every time mostly it failed do u know why its happend..Thanks in Adv mahendra
XMPPvCardTempModuleDelegate
provides the following 2 delegate methods to find out if your vCard was successfully updated on the server:
- (void)xmppvCardTempModuleDidUpdateMyvCard:(XMPPvCardTempModule *)vCardTempModule;
- (void)xmppvCardTempModule:(XMPPvCardTempModule *)vCardTempModule failedToUpdateMyvCard:(NSXMLElement *)error;
The issue might be because the image is too large (most servers only accepts 64x64 sized avatars), so try using a smaller image.
Thank you,these delegate method also not called in my case . can u plz tell me how i save my profile image in my core data in obj c.
Thanks Mahendra
updateMyvCardTemp:
does this, but if it failed to upload it will be (eventually) overridden with the servers vCard.
You don't it is done for you, read the header files and figure things out how else will you learn!!
Sent from my fruity device
On Jul 1, 2014, at 12:48 AM, KeyideasGlobal notifications@github.com wrote:
Thank you,these delegate method also not called in my case . can u plz tell me how i save my profile image in my core data in obj c.
Thanks Mahendra
\ Reply to this email directly or view it on GitHub.
Btw you should wrap the XMPP code outside of your viewControllers.
I use the [xmppvCardTempModule myvCardTemp], did not enter the delegate methods ,
Hi, Plz tell me how i get my friends nic name and picture in when they are offline also in obj c
Thanks in Adv Mahendra