Sharing image exclusively with another app
I have two I apps, sender and receiver, and I want to exclusively share a photo with receiver, how can I share directly with the receiver so I don't have to present an action sheet to the user?
I know I can use this to open an app:
[[UIApplication sharedApplication] openURL:recieverURL];
But I don't know how to send a photo to the app unless I use UIDocumentInteractionController which then I have to use an action sheet:
// 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];
}
I have two I apps, sender and receiver, and I want to exclusively share a photo with receiver, how can I share directly with the receiver so I don't have to present an action sheet to the user?
I know I can use this to open an app:
[[UIApplication sharedApplication] openURL:recieverURL];
But I don't know how to send a photo to the app unless I use UIDocumentInteractionController which then I have to use an action sheet:
// 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];
}
No comments:
Post a Comment