My client wants to share an image on Instagram, Twitter, Facebook.

I have done Twitter and Facebook but did not find any API or any thing on internet to share image on Instagram. Is it possible to share image on Instagram? if yes then how?

When I check the developer site of Instagram I have found the Libraries of Ruby on Rails and Python. But there are no documentation of iOS Sdk

I have get token from instagram as per instagram.com/developer but now don't know what to do next step for sharing with instagram image.

推荐答案

Finally I got the answer. you can not directly post an image on instagram. You have to rediredt your image with UIDocumentInteractionController.

@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]];
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;
}

NOTE : once you redirect to instagram app you can not back to your app. you have to open your app again

Download source from here

Ios相关问答推荐

SWIFT设备方向更新不正确

TrueDepth摄像机像素距离不准确

如何使用超薄material ,但没有浅色/填充?

如何在SwiftUI中顺时针和逆时针两个方向应用旋转效果?

SwiftUI Divider过大了其父视图

当S没有身体时该如何处理

围绕对象旋转和移动相机不起作用Swift SceneKit

Flutter应用内购买无法恢复购买

从包含 5 个以上项目的自定义选项卡栏的导航视图中删除更多按钮

如何为 Firebase Auth 实施 Firebase AppCheck?

如何在 SwiftUI 中创建两个大小相同的正方形占据整个屏幕宽度?

使用 Foundation 解压缩文件

react 在 android 上运行的本机应用程序,但在 iOS 上出现问题,详细信息在描述中共享

搜索在 ios xamarin.forms 中不起作用

SensorKit - 获取数据不调用结果委托函数

无法同时满足约束 - 没有适当的约束

在 React Native 中保存敏感数据

使用 swift 从应用程序委托打开视图控制器

SwiftUI 应用生命周期 iOS14 AppDelegate 代码放哪里?

zoom UIButton 动画 - Swift