iOS sdk和Instagram

art*_*dev 4 objective-c ios instagram

有没有办法在分享图像到Instagram后打开我的应用程序?

我对Instagram代码的分享:

[Utils saveImage:self.pickedImage withName:@"image.igo"];

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

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,     NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *imagePath = [documentsDirectory stringByAppendingPathComponent:@"image.igo"];

NSURL *igImageHookFile = [NSURL fileURLWithPath:imagePath];
self.docFile=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];
self.docFile.UTI = @"com.instagram.exclusivegram";
self.docFile.annotation = [NSDictionary dictionaryWithObject: self.descrText forKey:@"InstagramCaption"];

NSURL *instagramURL = [NSURL URLWithString:@"instagram://media?id=MEDIA_ID"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
    [self.docFile presentOpenInMenuFromRect: rect    inView: self.view animated: YES ];
}
else {
    [Utils simpleAlertWithTitle:LOC(@"You have not Instagram app in device.") message:nil];
}
Run Code Online (Sandbox Code Playgroud)

此后打开分享屏幕打开Instagram应用程序.我想在点击Instagram应用程序中的"共享"按钮后返回我的应用程序,并获得有关共享照片(userId,photoUrl等等)的回调.

可能吗?

谢谢.

Pra*_*tel 6

Hope this answer will resolve your query. This will directly opens library folder in Instagram instead of Camera.

        NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
        if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
        {
            NSURL *videoFilePath = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[request downloadDestinationPath]]]; // Your local path to the video
            NSString *caption = @"Some Preloaded Caption";
            ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
            [library writeVideoAtPathToSavedPhotosAlbum:videoFilePath completionBlock:^(NSURL *assetURL, NSError *error) {
                NSString *escapedString   = [self urlencodedString:videoFilePath.absoluteString];
                NSString *escapedCaption  = [self urlencodedString:caption];
                NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@",escapedString,escapedCaption]];
                if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
                    [[UIApplication sharedApplication] openURL:instagramURL];
                }
            }];
Run Code Online (Sandbox Code Playgroud)