简体   繁体   中英

XMPP Framework sending files

I managed to successfully send a file from iphone to spark. Now I want to send a file from iphone to iphone, unfortunately I always get this error code: Printing description of error: Error Domain = XMPPOutgoingFileTransferErrorDomain Code = -1 "Unable to send SI offer; the recipient does not have the required features." UserInfo = {0x1a9773d0 NSLocalizedDescription = Unable to send SI offer; the recipient does not have the required features.}

The code I'm using for the transfer and the following:

-(void)elaborazioneInvioTraferimentoFile{

XMPPOutgoingFileTransfer *xmppIncomingFileTransfer= [XMPPOutgoingFileTransfer new];
[xmppIncomingFileTransfer activate:self.xmppStream];

[xmppIncomingFileTransfer addDelegate:self delegateQueue:dispatch_get_main_queue()];



UIImage *img=[UIImage imageNamed:@"ico.png"];

NSData *pngData = UIImagePNGRepresentation(img);
NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths1 objectAtIndex:0]; //Get the docs directory
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"ico.png"]; //Add the file name
[pngData writeToFile:filePath atomically:YES]; //Write the file

// do error checking fun stuxmppIncomingFileTransferff...

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                     NSUserDomainMask,
                                                     YES);
NSString *fullPath = [[paths lastObject] stringByAppendingPathComponent:@"ico.png"];
NSData *data = [NSData dataWithContentsOfFile:fullPath];

NSLog(@"******%@",self.senderId);

NSError *err;
if (![xmppIncomingFileTransfer sendData:data
                                  named:@"ico.png"
                            toRecipient:[XMPPJID jidWithString:self.senderId]
                            description:@"Baal's Soulstone, obviously."
                                  error:&err]) {
    DDLogInfo(@"You messed something up: %@", err);
}

}

Where am I doing wrong? thanks for your help

For send File from iPhone to iPhone, you have to upload image or file to specific your server and after successfully upload on server you have to send that uploaded file URL to another iPhone user. So that second user can download file from that specific URL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM