Question

We have a map-based Android app in the making, and we have a pop up on the markers on the map with info. We have integrated a Facebook icon that just links to the Facebook page of the marker.

We are being told by the company building our app that Instagram cannot at this time be implemented due to Instagram not publishing "SDKs/APIs" yet?

Is this true or can we integrate an "Instagram" icon to our popup info box from the marker on the map that would link to the desired page?

Can anyone help?

Was it helpful?

Solution

i am sharing image on instagram implementing below code. Please follow this code, i think this will help you for iOS development.

In your .h file add a Delegate Method ." UIDocumentInteractionControllerDelegate "

And declare UIDocumentInteractionController *docController;

In your .m File where you want to share the image on Instagram, write this code on click instagram button action.

-(void)instagramshare_action
{     
    NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"];

            if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
            {
                NSFileManager *fileManager = [NSFileManager defaultManager] ;
                NSArray *path=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
                NSString *imagePath=[path objectAtIndex:0];
                imagePath =[imagePath stringByAppendingPathComponent:@"ResizeImage"];
                NSArray *temp=[fileManager contentsOfDirectoryAtPath:imagePath error:nil];
                NSString *tempImgPath = [imagePath stringByAppendingPathComponent:[temp objectAtIndex:0]];
                NSData *imgData = [NSData dataWithContentsOfFile:tempImgPath];
                UIImage *img = [UIImage imageWithData:imgData];

                CGRect rect = CGRectMake(0,0 ,612,612);
                [img drawInRect:rect];
                CGRect cropRect5 = CGRectMake(0,0,612,612);
                UIGraphicsBeginImageContextWithOptions(cropRect5.size,2.0,1.0);
                [img drawInRect:cropRect5];
                UIImage * customScreenShot = UIGraphicsGetImageFromCurrentImageContext();
                NSLog(@" custom sc==%@",customScreenShot);
                UIGraphicsEndImageContext();

                //saving to document directory
                NSArray *paths10 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
                NSString *documentsDirectory10 = [paths10 objectAtIndex:0];
                NSString *ImageName10 = [NSString stringWithFormat:@"image.png"];

                NSString* appFile = [documentsDirectory10 stringByAppendingPathComponent:ImageName10];
                NSLog(@"appFile==%@",appFile);
                NSData*  myImageAsData = [NSData dataWithData:UIImagePNGRepresentation(customScreenShot)];
                [myImageAsData writeToFile:appFile atomically:YES];

                //getting image(png format) from document directory and again saving with ig format
                NSString *ImageName1 =@"image.png";
                NSString *getImagePath =[documentsDirectory10 stringByAppendingPathComponent:ImageName1];

                UIImage *img1 = [UIImage imageWithContentsOfFile:getImagePath];

                NSData *data = UIImageJPEGRepresentation(img1, 1.0);
                UIImage *images = [[UIImage alloc] initWithData:data];

                NSLog(@"img==%@",images);
                CGRect rect2 = CGRectMake(0,0,612,612);

                [img1 drawInRect:rect2];

                NSString *ImageName = [NSString stringWithFormat:@"Image.ig"];

                NSString* appFile2 = [documentsDirectory10 stringByAppendingPathComponent:ImageName];
                NSLog(@"appFile==%@",appFile2);
                NSData*  myImageAsData2 = [NSData dataWithData:UIImagePNGRepresentation(img1)];
                NSLog(@"myimagedata==%@",myImageAsData2);
                NSURL *imageUrl = [NSURL fileURLWithPath:appFile2];
                [myImageAsData2 writeToFile:appFile2 atomically:YES];
                docController = [[UIDocumentInteractionController alloc] init];
                docController.delegate = self;
                [docController retain];
                docController.UTI = @"com.instagram.photo";
                [docController setURL:imageUrl];
                CGRect rect4=CGRectMake(0,0,320,480);
                [docController presentOpenInMenuFromRect:rect4 inView:self.view animated:YES];
            }
            else
            {
                UIAlertView *errorToShare = [[UIAlertView alloc] initWithTitle:@"Instagram unavailable " message:@"You need to install Instagram in your device in order to share this image" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                [errorToShare show];
                [errorToShare release];
            }
}


Important : You have to install Instagram App on your device otherwise i write the code for showing alert. And for checking with `instagram` you have to create a account on `instagram`

I think this will help you, implementation for instagram for iOS . :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top