Using UIImagePickerController, I'm able to get the Asset Path for a Media like assets-library://asset/asset.MOV?id=2A2CE6C9-C178-4395-977B-E6F159BF6D5E&ext=MOV
.
NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@",[referenceURL absoluteString], strInstagramCaption]];
Now, I want to convert this Asset Path into NSURL to pass it into following code block :
if ([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
[[UIApplication sharedApplication] openURL:instagramURL];
}
This is the way how you should convert asset path to valid NSUrl
:-
NSURL *instagramURL = [NSURL URLWithString:[[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@",[assetURL absoluteString],caption]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
}
Referred from this