Open image with Instagram

Hi, I need to import the edited image into Instagram, something like PhotoStudio:

enter image description here

I recorded my image using this code:

UIGraphicsBeginImageContextWithOptions(self.captureView.bounds.size, self.captureView.opaque, 0.0); [self.captureView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 

Then I need to open this screenShot using Instagram:


EDITED

I implement the method as follows:

  UIGraphicsBeginImageContextWithOptions(self.captureView.bounds.size, self.captureView.opaque, 0.0); [self.captureView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", screenshot]]; docFile.UTI = @"com.instagram.photo"; [self setupDocumentControllerWithURL:igImageHookFile]; NSURL *instagramURL = [NSURL URLWithString:@"instagram://media?id=MEDIA_ID"]; if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) { [[UIApplication sharedApplication] openURL:instagramURL]; } else { NSLog(@"No Instagram Found"); } } 

But I get this output:

 2012-05-05 21:55:36.842 InstantFrame[855:707] *** Assertion failure in -[UIDocumentInteractionController setURL:], /SourceCache/UIKit/UIKit-1914.84/UIDocumentInteractionController.m:1094 2012-05-05 21:55:36.848 InstantFrame[855:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIDocumentInteractionController: invalid scheme (null). Only the file scheme is supported.' 

Instagram will be open, but will not import anything.

+6
source share
2 answers

What you want to do is open a specially formatted URL.

Here is the instragram documentation I found with google quick search:

http://instagr.am/developer/iphone-hooks/

Here are the apple documents describing the URL scheme process. http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007891-SW1

+1
source

To share an image on Instagram, the minimum image size must be 612x612. Another wise he does not import the image.

0
source

Source: https://habr.com/ru/post/914974/


All Articles