Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instagram hook com.instagram.exclusivegram not so exclusive

As far as I know, you have to use com.instagram.photo to get the general options and com.instagram.exclusivegram for the documentinteractioncontroller's UTI if you really only want Instagram + use the correct extension .ig for general and .igo for exclusive Instagram.

For some reason, I see multiple options and not just Instagram like I want to..

Did I forgot something? Is it done differently?

UIImage *image = (UIImage *)[info valueForKey:UIImagePickerControllerOriginalImage];

NSURL *instagramURL = [NSURL URLWithString:@"instagram://"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
    CGRect rect = CGRectMake(0,0,0,0);
    CGRect cropRect=CGRectMake(0,0,612,612);
    // ig voor gewone instagram, igo voor exclusive instagram
    NSString *jpgPath=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/temp/photo.igo"];
    CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], cropRect);
    UIImage *img = [[UIImage alloc] initWithCGImage:imageRef];
    CGImageRelease(imageRef);
    [UIImageJPEGRepresentation(img, 1.0) writeToFile:jpgPath atomically:YES];

    NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@",jpgPath]];
    // exclusive zou direct in de instagram app moeten openen, helaas toont hij meerdere opties met instagram ergenes helemaal achteraan
    self.documentInteractionController.UTI = @"com.instagram.exclusivegram";
    self.documentInteractionController = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
    self.documentInteractionController.annotation = [NSDictionary dictionaryWithObject:@"Alweer een Nostalgie deelnemer! #nostalgiebusje" forKey:@"InstagramCaption"];
    [self.documentInteractionController presentOpenInMenuFromRect: rect inView: self.view animated: YES ];
}

Screenshot

like image 257
wouterds Avatar asked Jan 17 '14 00:01

wouterds


3 Answers

Using the file extension igo is correct, and the number of apps that will appear in the list is considerably less than if you used ig. From my testing (iOS 9 only), the UTI made no difference to the presented list.

Looks like the iPhone hooks doc is outdated.

like image 72
Ric Santos Avatar answered Nov 18 '22 09:11

Ric Santos


self.documentInteractionController.UTI = @"com.instagram.exclusivegram";
self.documentInteractionController = [self setupControllerWithURL:igImageHookFile usingDelegate:self];

It seems that UTI string is overwritten by setupControllerWithURL:usingDelegate: method.

like image 28
vokilam Avatar answered Nov 18 '22 08:11

vokilam


You need to create a temporary copy of the image with a "ig" or "igo" extension, then share that with UTI "com.instagram.exclusivegram". This should present the DocumentInteractionController with only the Instagram option:

if (![fm fileExistsAtPath:tempDirectory])
[fm createDirectoryAtPath:tempDirectory withIntermediateDirectories:YES attributes:nil error:nil];

NSString *tempInstagramPath = [tempDirectory stringByAppendingPathComponent:@"instagramShare.igo"];
if ([fm fileExistsAtPath:tempInstagramPath])
    [fm removeItemAtPath:tempInstagramPath error:nil];

[UIImageJPEGRepresentation(imageToShare, 1.0) writeToFile:tempInstagramPath atomically:NO];

documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:tempInstagramPath]];
documentInteractionController.delegate = self;
documentInteractionController.UTI = @"com.instagram.exclusivegram";
documentInteractionController.annotation = @{@"InstagramCaption": @"My Photo Caption!"};
if (![documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated:YES])
    NSLog(@"Cannot open Document Interaction Controller for sharing with Instagram");
like image 2
devdavid Avatar answered Nov 18 '22 07:11

devdavid