WhatsApp图像共享iOS

Iro*_*Man 8 iphone objective-c ios whatsapp

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

Nit*_*hel 8

这可能是可能的使用documentationInteractionController.最近我使用波纹管代码共享图像从我们的应用程序到whatsApp,Line,微信,但是当你点击WhatsApp图标,然后你是WhatsApp你应用程序的导航应用程序,你必须手动返回你的应用程序.在ImageSharing之后,这不再重定向.

在.h文件中: -

@interface ViewController : UIViewController<UIDocumentInteractionControllerDelegate>
{
}

@property(nonatomic,retain) UIDocumentInteractionController *documentationInteractionController;
Run Code Online (Sandbox Code Playgroud)

在.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;

}
Run Code Online (Sandbox Code Playgroud)

  • 可以通过UIActivityViewController进行共享 (2认同)