Export Image to Instagram - iPhone

I have an image and I want to export it to Instagram, so I can post it.

The code I use is:

NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"]; if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) { NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"Image.igo"]; UIImage *image = [UIImage imageNamed:@"01.png"]; NSData *imageData = UIImagePNGRepresentation(image); [imageData writeToFile:savedImagePath atomically:YES]; NSURL *imageUrl = [NSURL fileURLWithPath:savedImagePath]; NSLog(@"%@",imageUrl); UIDocumentInteractionController *docController = [[UIDocumentInteractionController alloc] init]; docController.delegate = self; docController.UTI = @"com.instagram.exclusivegram"; docController.URL = imageUrl; //[docController setURL:imageUrl]; [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]; } 

When I launch the application, the application shows a button written by "Instagram", its icon, but when I touch it, the button disappears and nothing happens. The application did not crash, but nothing happened.

What did I miss in my code?

Relations Bruno

+4
source share
1 answer

I think the problem is that you are not saving the UIDocumentInteractionController . Make ivar for it in your class.

Make sure the documentInteractionController:didEndSendingToApplication: method is called in the delegate.

Also check out Instagram documentation: http://instagram.com/developer/iphone-hooks/

When launched, Instagram will immediately present our filter to the user. The image is preloaded and fits the size for Instagram. In addition to using the appropriate image format described above, our only requirement is that the image is at least 612 pixels and / or wide. For best results, Instagram prefers opening a JPEG, which is 612 pixels per square 612 pixels. If the image is larger, it will be changed dynamically.

To check Instagram installed, check the instagram://app URL instagram://app . instagram://location?id=LOCATION_ID URL instagram://location?id=LOCATION_ID is for location feeds only.

+3
source

All Articles