0
我正在使用swift 3在线卖家的应用程序。然后这些应用程序可以将这些项目分享到社交媒体中。但我有一个分享给Instagram的问题。每个应用都有自己的url方案来打开它的权利?你们可以帮我吗,Instagram的网址计划是什么,可以直接在Instagram上打开剪裁页面?如何将图片从我的应用程序分享到Instagram
我正在使用swift 3在线卖家的应用程序。然后这些应用程序可以将这些项目分享到社交媒体中。但我有一个分享给Instagram的问题。每个应用都有自己的url方案来打开它的权利?你们可以帮我吗,Instagram的网址计划是什么,可以直接在Instagram上打开剪裁页面?如何将图片从我的应用程序分享到Instagram
我已经使用照片框架的OBJ下,在资产获得的图像
-(void)savePostsPhotoBeforeSharing {
UIImageWriteToSavedPhotosAlbum(choosenImage, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL); //Choosen image is image that you need to send on Instagram
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo: (void *) contextInfo; {
[self sharePostOnInstagram]; // this function save image .io format and check if any error exist or not
}
-(void)sharePostOnInstagram. //this will share your selected image on Instagram through its installed app
{
PHFetchOptions *fetchOptions = [PHFetchOptions new];
fetchOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO],];
__block PHAsset *assetToShare;
PHFetchResult *result = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:fetchOptions];
[result enumerateObjectsUsingBlock:^(PHAsset *asset, NSUInteger idx, BOOL *stop) {
assetToShare = asset;
}];
if([assetToShare isKindOfClass:[PHAsset class]])
{
NSString *localIdentifier = assetToShare.localIdentifier;
NSString *urlString = [NSString stringWithFormat:@"instagram://library?LocalIdentifier=%@",localIdentifier];
NSURL *instagramURL = [NSURL URLWithString:urlString];
if ([[UIApplication sharedApplication] canOpenURL: instagramURL]) {
[[UIApplication sharedApplication] openURL: instagramURL];
} else {
UIAlertController *removedSuccessFullyAlert = [UIAlertController alertControllerWithTitle:@"Error!!" message:@"No Instagram Application Found!" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *firstAction = [UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleDefault handler:nil];
[removedSuccessFullyAlert addAction:firstAction];
[self presentViewController:removedSuccessFullyAlert animated:YES completion:nil];
}
}
}
当你想分享图片到Instagram的
[self savePostsPhotoBeforeSharing];
我的目标C做只是调用这个函数没有整合如果你想我可以分享该代码 –
我很高兴,如果你可以与我分享... –
@NurAinMdIsa,请查看附加的URL - https://stackoverflow.com/questions/36406515/post-uiimage-to- Instagram的 - 使用 - 迅速相似到slcomposeviewcontroller –