我设法成功地从iphone发送文件到spark。 现在我想从iphone发送文件到iphone,不幸的是我总是得到这个错误代码: 打印错误说明: 错误域= XMPPOutgoingFileTransferErrorDomain代码= -1"无法发送SI报价;收件人没有所需的功能。" UserInfo = {0x1a9773d0 NSLocalizedDescription =无法发送SI报价;收件人没有所需的功能。}
我用于传输的代码及以下内容:
- (无效)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);
}
}
我在哪里做错了?谢谢你的帮助
答案 0 :(得分:1)
对于从iPhone发送文件到iPhone,您必须将图像或文件上传到特定的服务器,并且在服务器上成功上传后,您必须将上传的文件URL发送给另一个iPhone用户。这样第二个用户就可以从该特定URL下载文件。