我想在Instagram上通过Feed或通过iOS中我的应用发送的直接消息分享一些文本。有人可以让我知道该怎么做吗?我已经尝试过Instagram API文档,但是使用此标题不起作用,唯一的图像在供稿或故事中共享。但是在Android中,它是使用Intent共享文本作为直接消息。
我尝试了以下代码:
@property(nonatomic, strong) UIDocumentInteractionController *docController;
-(void)InstagramBtnClick: (id)sender {
NSURL *myImgUrl = [NSURL URLWithString: @"https://www.materials-world.com/bricks/glen-gery/red/images/red_cliff_w12-DA.jpg"];
NSData * imageData = [[NSData alloc] initWithContentsOfURL: myImgUrl];
UIImage *imgShare = [[UIImage alloc] initWithData:imageData];
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
if([[UIApplication sharedApplication] canOpenURL:instagramURL]) //check for App is install or not
{
UIImage *imageToUse = imgShare;
NSString *documentDirectory=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *saveImagePath=[documentDirectory stringByAppendingPathComponent:@"Image.igo"];
NSData *imageData=UIImagePNGRepresentation(imageToUse);
[imageData writeToFile:saveImagePath atomically:YES];
NSURL *imageURL=[NSURL fileURLWithPath:saveImagePath];
self.docController=[[UIDocumentInteractionController alloc]init];
self.docController = [UIDocumentInteractionController interactionControllerWithURL:imageURL];
self.docController.delegate = self;
self.docController.annotation = [NSDictionary dictionaryWithObjectsAndKeys:@"Testing Caption Text", @"InstagramCaption", nil];
self.docController.UTI = @"com.instagram.exclusivegram";
UIViewController *vc = [self topMostController];
[self.docController presentOpenInMenuFromRect:CGRectMake(1, 1, 1, 1) inView:vc.view animated:YES];
}
else {
NSLog(@"Instagram App not Found");
}
}
还有其他选择,以便可以在iOS的共享内容中添加文本。