Skip to content

Commit 2537fc4

Browse files
Use original file name with extension
1 parent ddcc2d0 commit 2537fc4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ios/ReactNativeShareExtension.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,15 @@ - (void)extractDataFromContext:(NSExtensionContext *)context withCallback:(void(
110110
**/
111111

112112
UIImage *sharedImage;
113-
NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"RNSE_TEMP_IMG"];
114-
NSString *fullPath = [filePath stringByAppendingPathExtension:@"png"];
115-
113+
NSString *filePath = nil;
114+
NSString *fullPath = nil;
115+
116116
if ([(NSObject *)item isKindOfClass:[UIImage class]]){
117117
sharedImage = (UIImage *)item;
118+
fullPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"Image.png"];
118119
}else if ([(NSObject *)item isKindOfClass:[NSURL class]]){
119120
NSURL* url = (NSURL *)item;
121+
fullPath = [NSTemporaryDirectory() stringByAppendingPathComponent:url.lastPathComponent];
120122
NSData *data = [NSData dataWithContentsOfURL:url];
121123
sharedImage = [UIImage imageWithData:data];
122124
}
@@ -126,6 +128,7 @@ - (void)extractDataFromContext:(NSExtensionContext *)context withCallback:(void(
126128
if(callback) {
127129
callback(fullPath, [fullPath pathExtension], nil);
128130
}
131+
129132
}];
130133
} else if (textProvider) {
131134
[textProvider loadItemForTypeIdentifier:TEXT_IDENTIFIER options:nil completionHandler:^(id<NSSecureCoding> item, NSError *error) {

0 commit comments

Comments
 (0)