Open iqqmuT opened 2 years ago
Great. Thanks.
In the ShareMenuReactView
class, I noticed a variable name inconsistency in the extractDataFromContext
function.
The issue is in this block of code:
let imageData: Data! = image.pngData();
// Creating a temporary URL for image data (UIImage)
guard let imageURL = NSURL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("TemporaryScreenshot.png") else {
return
}
do {
// Writing the image to the URL
try imageData.write(to: imageURL)
results.append([DATA_KEY: imageUrl.absoluteString, MIME_TYPE_KEY: imageURL.extractMimeType()])
} catch {
callback(nil, NSException(name: NSExceptionName(rawValue: "Error"), reason:"Can't load image", userInfo:nil))
}
The temporary variable defined for "TemporaryScreenshot.png" is imageURL, but it is incorrectly used as imageUrl here:
results.append([DATA_KEY: imageUrl.absoluteString, MIME_TYPE_KEY: imageURL.extractMimeType()])
To fix this issue, you should change it to:
results.append([DATA_KEY: imageURL.absoluteString, MIME_TYPE_KEY: imageURL.extractMimeType()])
Add this in your ShareViewController
in the storeFile
function
ShareViewController
if let uiImage = data as? UIImage {
let fileExtension = "png"
let fileName = UUID().uuidString
let filePath = groupFileManagerContainer
.appendingPathComponent("\(fileName).\(fileExtension)")
guard let rawData: Data = uiImage.pngData() else {
self.exit(withError: "Error while getting raw data")
return
}
guard FileManager.default.createFile(atPath: filePath.path, contents: rawData) else {
self.exit(withError: "Error while createFile")
return
}
self.sharedItems.append([DATA_KEY: filePath.absoluteString, MIME_TYPE_KEY: "image/png"])
semaphore.signal()
return
}
There seems to be a bug that causes a crash on iOS at least when sharing from Medium app.
The fix:
imageUrl
should beimageURL
inios/Modules/ShareMenuReactView.swift
.