From fdc39dc371a23263df489eb04f0e684496d3ce2b Mon Sep 17 00:00:00 2001 From: Yogendra Shelke Date: Fri, 10 Jul 2026 19:41:49 +0530 Subject: [PATCH] fix: resolve photo capture issues in TakePicture and TakePictureAdvanced actions on Android --- packages/jsActions/mobile-resources-native/CHANGELOG.md | 6 +++++- .../mobile-resources-native/src/camera/TakePicture.ts | 7 ++++--- .../src/camera/TakePictureAdvanced.ts | 7 ++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/jsActions/mobile-resources-native/CHANGELOG.md b/packages/jsActions/mobile-resources-native/CHANGELOG.md index 23064ccbd..2c1333ac0 100644 --- a/packages/jsActions/mobile-resources-native/CHANGELOG.md +++ b/packages/jsActions/mobile-resources-native/CHANGELOG.md @@ -6,10 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] -## [12.2.0] Native Mobile Resources - 2026-7-3 +### Fixed +- Fixed an issue where the `TakePicture` and `TakePictureAdvanced` actions failed to capture photos on Android. + +## [12.2.0] Native Mobile Resources - 2026-7-3 ## [5.3.1] BottomSheet + ### Fixed - Fixed flickering issue on Android when opening bottom sheet (both basic and custom render types). diff --git a/packages/jsActions/mobile-resources-native/src/camera/TakePicture.ts b/packages/jsActions/mobile-resources-native/src/camera/TakePicture.ts index 324d6c15d..8cd9ab8c8 100644 --- a/packages/jsActions/mobile-resources-native/src/camera/TakePicture.ts +++ b/packages/jsActions/mobile-resources-native/src/camera/TakePicture.ts @@ -118,9 +118,10 @@ export async function TakePicture( function storeFile(imageObject: mendix.lib.MxObject, uri: string): Promise { return new Promise((resolve, reject) => { - fetch(uri) - .then(response => response.blob()) - .then(blob => { + NativeModules.MxFileSystem.read(uri.replace("file://", "")) + .then((nativeBlob: unknown) => { + const blob = new Blob(); + Object.assign(blob, { data: nativeBlob }); // eslint-disable-next-line no-useless-escape const filename = /[^\/]*$/.exec(uri)![0]; const filePathWithoutFileScheme = uri.replace("file://", ""); diff --git a/packages/jsActions/mobile-resources-native/src/camera/TakePictureAdvanced.ts b/packages/jsActions/mobile-resources-native/src/camera/TakePictureAdvanced.ts index c141b842e..6a9dc43f6 100644 --- a/packages/jsActions/mobile-resources-native/src/camera/TakePictureAdvanced.ts +++ b/packages/jsActions/mobile-resources-native/src/camera/TakePictureAdvanced.ts @@ -171,9 +171,10 @@ export async function TakePictureAdvanced( function storeFile(imageObject: mendix.lib.MxObject, uri: string): Promise { return new Promise((resolve, reject) => { - fetch(uri) - .then(response => response.blob()) - .then(blob => { + NativeModules.MxFileSystem.read(uri.replace("file://", "")) + .then((nativeBlob: unknown) => { + const blob = new Blob(); + Object.assign(blob, { data: nativeBlob }); // eslint-disable-next-line no-useless-escape const filename = /[^\/]*$/.exec(uri)![0]; const filePathWithoutFileScheme = uri.replace("file://", "");