1

I'm using the following Instagram hook to post an image to Instagram. In iOS 8, the Instagram app was showing by itself in the UIDocumentInteractionController, but in iOS 9 it shows other options alongside it. Anyone know why this may be and how to resolve this so that only Instagram shows again?

UIImage *screenShot = self.shareableImage.image;
NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.ig"];
[UIImagePNGRepresentation(screenShot) writeToFile:savePath atomically:YES];

CGRect rect = CGRectMake(0 ,0 , 0, 0);


NSURL *instagramURL = [NSURL URLWithString:@"instagram://media?id=MEDIA_ID"];

NSString *documentDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
// *.igo is exclusive to instagram
NSString *saveImagePath = [documentDirectory stringByAppendingPathComponent:@"Image.igo"];
NSData *imageData = UIImagePNGRepresentation(screenShot);
[imageData writeToFile:saveImagePath atomically:YES];

NSURL *imageURL=[NSURL fileURLWithPath:saveImagePath];

self.dic=[[UIDocumentInteractionController alloc]init];
self.dic.delegate=self;
self.dic.UTI=@"com.instagram.photo";
[self.dic setURL:imageURL];

if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {

    [self.dic presentOpenInMenuFromRect: rect    inView: self.view animated: YES ];

}
else
{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:[NSString stringWithFormat:NSLocalizedString(@"imageShareViewNoInstagramAccountAlertTitle", nil)] message:[NSString stringWithFormat:NSLocalizedString(@"imageShareViewNoInstagramAccountAlertMessage", nil)]delegate:nil cancelButtonTitle:[NSString stringWithFormat:NSLocalizedString(@"imageShareViewNoFacebookAccountAlertCancelButton", nil)]otherButtonTitles:nil, nil];


    [alert show];

}

- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL usingDelegate: (id <UIDocumentInteractionControllerDelegate>) interactionDelegate
{
UIDocumentInteractionController *interactionController = [UIDocumentInteractionController interactionControllerWithURL: fileURL];
interactionController.delegate = interactionDelegate;
return interactionController;
}
embersofadyingfire
  • 523
  • 1
  • 4
  • 16

1 Answers1

0

Try changing com.instagram.photo to com.instagram.exclusivegram.

Cheers!

Balázs Vincze
  • 3,550
  • 5
  • 29
  • 60
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). – Vojtech Vrbka Oct 21 '15 at 11:04
  • According to the official Instagram documentation, it should solve the question. – Balázs Vincze Oct 21 '15 at 11:06
  • 1
    But it does not – tommybananas Mar 26 '18 at 03:57