Skip to content

Commit 95817f3

Browse files
Use original file name with extension
1 parent ddcc2d0 commit 95817f3

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

ios/ReactNativeShareExtension.m

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ - (void)viewDidLoad {
6868
}
6969

7070
- (void)extractDataFromContext:(NSExtensionContext *)context withCallback:(void(^)(NSString *value, NSString* contentType, NSException *exception))callback {
71-
7271
@try {
7372
NSExtensionItem *item = [context.inputItems firstObject];
7473
NSArray *attachments = item.attachments;
@@ -108,15 +107,17 @@ - (void)extractDataFromContext:(NSExtensionContext *)context withCallback:(void(
108107
* Therefore the solution is to save a UIImage, either way, and return the local path to that temp UIImage
109108
* This path will be sent to React Native and can be processed and accessed RN side.
110109
**/
111-
110+
112111
UIImage *sharedImage;
113-
NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"RNSE_TEMP_IMG"];
114-
NSString *fullPath = [filePath stringByAppendingPathExtension:@"png"];
115-
112+
NSString *filePath = nil;
113+
NSString *fullPath = nil;
114+
116115
if ([(NSObject *)item isKindOfClass:[UIImage class]]){
117116
sharedImage = (UIImage *)item;
117+
fullPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"Image.png"];
118118
}else if ([(NSObject *)item isKindOfClass:[NSURL class]]){
119119
NSURL* url = (NSURL *)item;
120+
fullPath = [NSTemporaryDirectory() stringByAppendingPathComponent:url.lastPathComponent];
120121
NSData *data = [NSData dataWithContentsOfURL:url];
121122
sharedImage = [UIImage imageWithData:data];
122123
}
@@ -148,6 +149,4 @@ - (void)extractDataFromContext:(NSExtensionContext *)context withCallback:(void(
148149
}
149150
}
150151

151-
152-
153152
@end

0 commit comments

Comments
 (0)