Reputation: 640
I'm developping share image to the other apps, including WhatsApp
.
I'm using this code and it works.
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]]){
UIImage *image = [self processImage:sender];
NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"];
[UIImageJPEGRepresentation(image, 1.0) writeToFile:savePath atomically:YES];
_documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
_documentInteractionController.delegate = self;
_documentInteractionController.UTI = @"net.whatsapp.image";
[_documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
}else {
[self showAlertTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed."];
}
The problem is, when I run this code, documentInteractionController
presents the other options apps like this image, so I must pick WhatsApp first before it open WhatsApp application.
Can I select Whatsapp App to share the file without presenting the menu for choosing? In other words, can I avoid presentOpenInMenuFromRect
?
I`m using iOS 9 and this issue happen also with my Instagram post
Upvotes: 2
Views: 1068
Reputation: 1033
Yes. you can write this code. After run code do the following.
Step:1 Add LSApplicationQueriesSchemes in Info.plist
Step:2 Add whatsapp in items.
Upvotes: 2