I am trying to share an image on the Instagram application through my application.
Please check my code below and please let me know where I have gone wrong.
_instagramURL = [NSURL URLWithString:[NSString stringWithFormat: @"instagram://media?id=%@",[SingletoneClass sharedSingleTone].imageId]];
if ([[UIApplication sharedApplication] canOpenURL:_instagramURL]) {
self.dic = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:[SingletoneClass sharedSingleTone].imagePath]];
self.dic.delegate = self;
self.dic.UTI = @"com.instagram.exclusivegram";
self.dic.annotation = [NSDictionary dictionaryWithObject:[SingletoneClass sharedSingleTone].captionStr forKey:@"InstagramCaption"];
[self.dic presentOpenInMenuFromRect: CGRectZero inView:self.view animated:YES ];
}
else {
UIAlertController *alert = [[SingletoneClass sharedSingleTone] setAlertControllerWithTitle:@"" message:@"Instagram is not present in your device" andCallback:^(id actionResponse) {
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[self presentViewController:alert animated:YES completion:nil];
}
If above code is correct, then please let me know, from where I can find the imageId?
Check Below code for share image on Instagram , its working fine
import
-(void)shareImageOnInstagram:(UIImage *)image { if(![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"instagram://"]]) { //Your device doesn't have Instagram app. return; }
}