Skip to content

Commit

Permalink
fix: 🐛 fix sharing on iOS #111
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigograca31 committed Apr 10, 2020
1 parent 3620b63 commit a5d8be4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/ios/CDVInstagramPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ a copy of this software and associated documentation files (the
#import <Cordova/CDV.h>
#import "CDVInstagramPlugin.h"

#define IS_IOS13orHIGHER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 13.0)

static NSString *InstagramId = @"com.burbn.instagram";

@implementation CDVInstagramPlugin
Expand Down Expand Up @@ -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};
}
Expand Down

0 comments on commit a5d8be4

Please sign in to comment.