これは私のコードです。ファイルは写真ライブラリに正しく追加されていますが、instagramアプリではこのURL - >instagram://library?AssetPath=assets-library%3A%2F%2Fasset%2Fasset.mp4%3Fid=5EDBD113-FF57-476B-AABB-6A59F31170B5&ext=mp4&InstagramCaption=my%caption
は最後の動画を開きません。Instagramフックメディア選択の事前選択
- (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
@scientifficそれを修正する方法を見つけることができませんでしたが、今は私はこのチケットを無視しています。 – jose920405
@ jose920405悲しいことに、どうもありがとう。 – saiday