0

when sharing the UIImage to the facebook/twitter getting the error

LaunchServices: invalidationHandler called

-(IBAction)ShareBtnClicked:(id)sender {
[self calculateInterstitialAdsCounts];

NSURL *fileURL;
docInteracCont.delegate = self;

//Save the Image to default Document directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:TEMP_PIC_NAME];

self.rawImage = _imageView.image;

BOOL prefs = [[NSUserDefaults standardUserDefaults ]boolForKey:WATERMARK_REMOVED];
if(!prefs)
{
    self.rawImage = [Utility imageWithWaterMark:_imageView.image];
}


NSData *imageData = UIImageJPEGRepresentation(self.rawImage, 1.0);

[imageData writeToFile:savedImagePath atomically:false];
NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:TEMP_PIC_NAME];
fileURL = [[NSURL alloc] initFileURLWithPath:getImagePath];

// Open the Document Interaction controller for Sharing options (in Menu) 
// docInteracCont = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
// [docInteracCont presentOpenInMenuFromRect:CGRectZero inView:self.view animated:true];
NSArray *objectsToShare = @[textToShare, fileURL];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];

activityVC.excludedActivityTypes = @[UIActivityTypeCopyToPasteboard];
activityVC.popoverPresentationController.sourceView = self.view;

[self presentViewController:activityVC animated:YES completion:nil];
}

and not able to find why the error is caused. Deployment target 7.0 running on iPhone5 App is universal i.e. for both iPad and iPhone. Error is coming but images are still shared on facebook and i want to implement video Ads on the app and getting path how to implement it. plz share some idea

Ankur
  • 1
  • 4
  • Have a look at: http://stackoverflow.com/questions/25192313/sharing-via-uiactivityviewcontroller-to-twitter-facebook-etc-causing-crash, change target to 8.0 – Ramesh Kumar Apr 08 '16 at 12:12
  • Okay i'm changing deployment target to 8.0, i have seen that link that code is in swift my code is in Objective C – Ankur Apr 08 '16 at 12:23
  • still getting same error. – Ankur Apr 08 '16 at 12:33
  • this might works for you http://stackoverflow.com/questions/25937143/present-uiactivityviewcontroller-launchservicesinvalidationhandler-called – Avi Apr 11 '16 at 04:21

0 Answers0