From a5d8be4fa6e884dccee61b83bcce8a25103b5fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gra=C3=A7a?= Date: Fri, 10 Apr 2020 21:00:09 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20fix=20sharing=20on=20iOS?= =?UTF-8?q?=20#111?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ios/CDVInstagramPlugin.m | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ios/CDVInstagramPlugin.m b/src/ios/CDVInstagramPlugin.m index 1289693..276a99c 100644 --- a/src/ios/CDVInstagramPlugin.m +++ b/src/ios/CDVInstagramPlugin.m @@ -25,6 +25,8 @@ a copy of this software and associated documentation files (the #import #import "CDVInstagramPlugin.h" +#define IS_IOS13orHIGHER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 13.0) + static NSString *InstagramId = @"com.burbn.instagram"; @implementation CDVInstagramPlugin @@ -62,12 +64,24 @@ - (void)share:(CDVInvokedUrlCommand*)command { NSData *imageObj = [[NSData alloc] initWithBase64EncodedString:objectAtIndex0 options:0]; NSString *tmpDir = NSTemporaryDirectory(); - NSString *path = [tmpDir stringByAppendingPathComponent:@"instagram.igo"]; + NSString *path; + if (IS_IOS13orHIGHER) { + path = [tmpDir stringByAppendingPathComponent:@"instagram.ig"]; + } else { + path = [tmpDir stringByAppendingPathComponent:@"instagram.igo"]; + } + [imageObj writeToFile:path atomically:true]; self.interactionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]]; - self.interactionController .UTI = @"com.instagram.exclusivegram"; + + if (IS_IOS13orHIGHER) { + self.interactionController .UTI = @"com.instagram.photo"; + } else { + self.interactionController .UTI = @"com.instagram.exclusivegram"; + } + if (caption) { self.interactionController .annotation = @{@"InstagramCaption" : caption}; }