Instagram挂钩预选媒体问题 [英] Instagram hooks pre-select media issue

查看:634
本文介绍了Instagram挂钩预选媒体问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码。该文件已正确添加到照片库,但在Instagram应用中此网址 - > instagram://库?AssetPath = assets-library%3A%2F%2Fasset%2Fasset.mp4%3Fid = 5EDBD113-FF57 -476B-AABB-6A59F31170B5& ext = mp4& InstagramCaption = my%caption 不要打开最后一个视频。

This is my code. The file is correctly added to photos library, but in instagram app this url -> instagram://library?AssetPath=assets-library%3A%2F%2Fasset%2Fasset.mp4%3Fid=5EDBD113-FF57-476B-AABB-6A59F31170B5&ext=mp4&InstagramCaption=my%caption don't open the last video.

- (void)loadCameraRollAssetToInstagram:(NSURL*)assetsLibraryURL andMessage:(NSString*)message
{
    NSString *escapedString   = [self urlencodedString:assetsLibraryURL.absoluteString];
    NSString *escapedCaption  = [self urlencodedString:message];
    NSURL *instagramURL       = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@", escapedString, escapedCaption]];

    NSLog(@"instagramURL ==> %@",instagramURL);

    if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
        NSLog(@"Open Instagram!!");
        [[UIApplication sharedApplication] openURL:instagramURL];
    } else {
        NSLog(@"Cant open Instagram!!");
        [[[UIAlertView alloc] initWithTitle:@"Instagram" message:@"App not installed" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil] show];
    }
}

- (NSString*)urlencodedString:(NSString *)message
{
    return [message stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
}

- (void)saveToCameraRoll:(NSURL *)srcURL withCurrentAction:(NSString *)action
{
    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    ALAssetsLibraryWriteVideoCompletionBlock videoWriteCompletionBlock = ^(NSURL *newURL, NSError *error) {

        if (error) {
            NSLog( @"Error writing image with metadata to Photo Library: %@", error );
            [[[UIAlertView alloc] initWithTitle:@"Facebook" message:@"Pal - Currently we can't process your video. Please try again in few moments" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Sign In", nil] show];

        } else {
            NSLog( @"Wrote image with metadata to Photo Library: %@", newURL.absoluteString);
            if ([action isEqualToString:@"instagram"])
                [self loadCameraRollAssetToInstagram:newURL andMessage:@"My caption"]; //Can be any text?
        }
    };

    if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:srcURL])
    {
        [library writeVideoAtPathToSavedPhotosAlbum:srcURL completionBlock:videoWriteCompletionBlock];
    }
}

一些非常奇怪的东西是完美的,直到我转向卸载然后安装instagram。不知道这是否有事做法

something very strange is that worked perfect, until I turned uninstall and then install instagram. Do not know if this has something to do

推荐答案

instagram: // library?AssetPath = \(assetsLibraryUrl)
前一段时间停止工作。 Instagram开发人员可能转移到了Photos框架,不再使用AssetsLibrary。

instagram://library?AssetPath=\(assetsLibraryUrl) stopped working a while ago. Instagram developers probably moved to Photos framework and no longer use the AssetsLibrary.

有了这个假设,我尝试了其他几个参数名称,发现 instagram:/ / library?LocalIdentifier = \(localID)其中 localId 是你的 localIdentifier PHAsset 现在可以使用。

Having this assumption I tried several other parameter names and found that instagram://library?LocalIdentifier=\(localID) where localId is the localIdentifier of your PHAsset works for now.

这仍然没有文档记录,所以它可以在以后的任何版本中破坏Instagram。

This is still as undocumented as it was so it can break in any future version of the Instagram.

这篇关于Instagram挂钩预选媒体问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆