【发布时间】:2016-03-17 12:53:36
【问题描述】:
这是我的代码。该文件已正确添加到照片库,但在 instagram 应用程序中此 url -> instagram://library?AssetPath=assets-library%3A%2F%2Fasset%2Fasset.mp4%3Fid=5EDBD113-FF57-476B-AABB-6A59F31170B5&ext=mp4&InstagramCaption=my%caption 不要打开最后一个视频。
- (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。不知道这有没有关系
【问题讨论】:
-
你找到答案了吗?我遇到了同样的问题。
-
@scientiffic 无法找到修复它的方法,目前我忽略了这张票。
-
@jose920405 不幸的消息,还是谢谢你。
-
@jose920405 你能找到LocalIdentifier吗?
-
对不起@DevangGoswami,我没有时间尝试这个,因为我已经放弃了这个问题,我今天必须恢复,因为我需要这个用于另一个项目。查看我最近的回复 ==> stackoverflow.com/questions/34226433/…
标签: ios objective-c hook instagram