In my App I sharing an image on Instagram. It is working well in my app.
I am using the following code.
@property (nonatomic, retain) UIDocumentInteractionController *dic;
CGRect rect = CGRectMake(0 ,0 , 0, 0);
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndImageContext();
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/test.igo"];
NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", jpgPath]];
// NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", screenshot]];
self.dic.UTI = @"com.instagram.photo";
self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
[self.dic presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate {
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
interactionController.delegate = interactionDelegate;
return interactionController;
}
Now I also want to share some text with the image.
As shown in the Image below. In " Write a Caption", I want some default custom text for eg. "Share this photo".
How can I do this?
Thanks in advance...
Edited
I am opening Instagram from my app for sharing images and it works fine.
But Is it possible that Can I check Whether the user has shared it successfully or not?
Means I want to perform some action in my DB when user successfully shares an image.
How can i do this?
Instagram app for Android and iPhoneTap below the photo or video in Feed. Tap Add post/video/reel to your story. Tap in the bottom right. Tap Share.
Instagram app for Android and iPhoneTap in the top right. Select people you'd like to send a message to, then tap Chat. Type a message. You can also tap to take and send a disappearing photo or video, or to select a photo or video from your library.
I got my answer. Just added a line and it worked for me.
self.dic.annotation = [NSDictionary dictionaryWithObject:@"Here Give what you want to share" forKey:@"InstagramCaption"];
Thanks...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With