Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share text with Images on Instagram in ios

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

enter image description here

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?

like image 776
Manthan Avatar asked Apr 02 '13 10:04

Manthan


People also ask

How do I share an IOS post on Instagram?

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.

How do you share text on Instagram?

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.


1 Answers

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

like image 157
Manthan Avatar answered Oct 06 '22 01:10

Manthan