@@ -37,7 +37,6 @@ - (void)viewDidLoad {
3737 self.view = rootView;
3838}
3939
40-
4140RCT_EXPORT_METHOD (close) {
4241 [extensionContext completeRequestReturningItems: nil
4342 completionHandler: nil ];
@@ -119,21 +118,25 @@ - (void)extractDataFromContext:(NSExtensionContext *)context withCallback:(void(
119118 NSString *fullPath = nil ;
120119 NSString *path = nil ;
121120
121+ NSLog (@" [ITEM]: %@ " , (NSURL *)item);
122+
122123 if ([(NSObject *)item isKindOfClass: [UIImage class ]]){
123124 sharedImage = (UIImage *)item;
124125 fullPath = [NSTemporaryDirectory () stringByAppendingPathComponent: @" image.png" ];
126+ [UIImagePNGRepresentation (sharedImage) writeToFile: fullPath atomically: YES ];
127+ path = [NSString stringWithFormat: @" %@%@ " , @" file://" , fullPath];
128+ if (callback) {
129+ callback (path, @" media" , nil );
130+ }
125131 }else if ([(NSObject *)item isKindOfClass: [NSURL class ]]){
126132 NSURL * url = (NSURL *)item;
127- fullPath = [ NSTemporaryDirectory () stringByAppendingPathComponent: url.lastPathComponent];
128- NSData *data = [ NSData dataWithContentsOfURL: url] ;
129- sharedImage = [UIImage imageWithData: data];
133+ if (callback) {
134+ callback ([ url absoluteString ], @" media " , nil ) ;
135+ }
130136 }
131-
132- [UIImagePNGRepresentation (sharedImage) writeToFile: fullPath atomically: YES ];
133-
134- path = [NSString stringWithFormat: @" %@%@ " , @" file://" , fullPath];
137+
135138 if (callback) {
136- callback (path , @" media" , nil );
139+ callback (@" " , @" media" , nil );
137140 }
138141 }];
139142 } else if (textProvider) {
0 commit comments