我有两个我的应用程序,发送者和接收者,我想与接收者独家分享照片,我如何直接与接收者分享,这样我就不必向用户展示操作表?
我知道我可以用它来打开一个应用程序:
[[UIApplication sharedApplication] openURL:recieverURL];
但我不知道如何将照片发送到应用程序,除非我使用 UIDocumentInteractionController ,然后我必须使用操作表:
// within sender app
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"reciever://"]]) {
NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"filename.jpg"], 1.0);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *fullPathToFile = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"cameraawesome.ca"];
[imageData writeToFile:fullPathToFile atomically:NO];
self._interactionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@", self._filePath]]];
self._interactionController.UTI = @"com.myapp.exclusive";
self._interactionController.delegate = self;
[self._interactionController presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES];
}