【问题标题】:iOS sdk and InstagramiOS SDK 和 Instagram
【发布时间】:2014-01-22 14:45:47
【问题描述】:

在将图片分享到 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];
}

现在打开 Instagram 应用程序并打开共享屏幕。 我想在点击 Instagram 应用程序中的分享按钮后返回我的应用程序,并获取有关共享照片(userId、photoUrl 等)的一些回调。

有可能吗?

谢谢。

【问题讨论】:

    标签: ios objective-c instagram


    【解决方案1】:
    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];
                    }
                }];
    

    【讨论】:

      【解决方案2】:

      到目前为止,instagram 中还没有回调/x-callback 支持。用户需要手动切换回来。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-11-04
        • 2011-06-03
        • 2014-11-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多