WhatsApp的图像共享iOS

我正在开发一个iOS应用程序,我必须从我的应用程序共享WhatsApp上的图像。 我发现这个代码,但它只处理文本共享https://github.com/jberlana/JBWhatsAppActivity

这可以使用documentationInteractionController 。 最近我做了这个使用以下代码来分享图像从我们的应用程序到WhatsApp,Line,WeChat,但是当你点击WhatsApp图标,那么你是从你的应用程序导航WhatsApp应用程序,你必须手动返回你的应用程序。 ImageSharing之后不会再redirect。

在.h文件中: –

 @interface ViewController : UIViewController<UIDocumentInteractionControllerDelegate> { } @property(nonatomic,retain) UIDocumentInteractionController *documentationInteractionController; 

在.m文件中

 - (IBAction)bocClick:(UIButton *)sender { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"]; //here i am fetched image path from document directory and convert it in to URL and use bellow NSURL *imageFileURL =[NSURL fileURLWithPath:getImagePath]; NSLog(@"imag %@",imageFileURL); self.documentationInteractionController.delegate = self; self.documentationInteractionController.UTI = @"net.whatsapp.image"; self.documentationInteractionController = [self setupControllerWithURL:imageFileURL usingDelegate:self]; [self.documentationInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]; } - (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate { self.documentationInteractionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL]; self.documentationInteractionController.delegate = interactionDelegate; return self.documentationInteractionController; }