1

I am using a standard UIDocumentInteractionController in my app, and provide it with a local image URL. However, once Viber is selected, it first sends a plain text message with the file URL and then the image. I only want to send the image ofcourse. I see that it's working allright from the native Gallery, so it's obviously my fault. here's the code:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *docs = [paths objectAtIndex:0];
NSString* path =  [docs stringByAppendingFormat:@"/tempName.jpg"];

MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithView:imgPicker.view];
HUD.mode = MBProgressHUDModeAnnularDeterminate;
[imgPicker.view addSubview:HUD];
[HUD show:YES];

       dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
           NSData* imageData = [NSData dataWithData:UIImageJPEGRepresentation(image, 80)];
           NSError *writeError = nil;
           [imageData writeToFile:path options:NSDataWritingAtomic error:&writeError];
           _documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL URLWithString:path]];
           [_documentInteractionController setUTI:(NSString *)kUTTypeJPEG];
           _documentInteractionController.delegate = self;
           dispatch_async(dispatch_get_main_queue(), ^{
               //Your main thread code goes in here
               [HUD removeFromSuperview];
               [_documentInteractionController presentOptionsMenuFromRect:CGRectZero inView:imgPicker.view animated:YES];                   });

});
Leo Starić
  • 331
  • 1
  • 4
  • 16

0 Answers0