From fd7af7d197e88c745702ded7b661fa9d7b37abf3 Mon Sep 17 00:00:00 2001 From: "Srirang.Kalantri" Date: Thu, 2 Apr 2026 16:42:05 +0530 Subject: [PATCH] fix: change the depricated function and fix updated api --- packages/jsActions/mobile-resources-native/CHANGELOG.md | 5 +++++ .../src/camera/SaveToPictureLibrary.ts | 4 ++-- .../src/file-download/DownloadFile.ts | 2 +- .../mobile-resources-native/src/platform/PlaySound.ts | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/jsActions/mobile-resources-native/CHANGELOG.md b/packages/jsActions/mobile-resources-native/CHANGELOG.md index 741f53e4b..1bcca1ec1 100644 --- a/packages/jsActions/mobile-resources-native/CHANGELOG.md +++ b/packages/jsActions/mobile-resources-native/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Changed + +- We replaced the depricated CameraRoll.saveToCameraRoll with CameraRoll.saveAsset in SaveToPictureLibrary activity. +- Add await to API calls updated to async in recent update + ## [11.4.1] Native Mobile Resources - 2026-3-14 ## [2.0.2] GalleryTextFilter diff --git a/packages/jsActions/mobile-resources-native/src/camera/SaveToPictureLibrary.ts b/packages/jsActions/mobile-resources-native/src/camera/SaveToPictureLibrary.ts index 86b7e78b3..efd04e917 100644 --- a/packages/jsActions/mobile-resources-native/src/camera/SaveToPictureLibrary.ts +++ b/packages/jsActions/mobile-resources-native/src/camera/SaveToPictureLibrary.ts @@ -29,11 +29,11 @@ export async function SaveToPictureLibrary(picture?: mendix.lib.MxObject): Promi const guid = picture.getGuid(); const changedDate = picture.get("changedDate") as number; - const url = mx.data.getDocumentUrl(guid, changedDate); + const url = await mx.data.getDocumentUrl(guid, changedDate); // Save the file as a photo to the camera roll. try { - const savedUri = await CameraRoll.saveToCameraRoll(url, "auto"); + const savedUri = await CameraRoll.saveAsset(url); return Promise.resolve(savedUri.node.image.uri); } catch (error) { return Promise.reject(error); diff --git a/packages/jsActions/mobile-resources-native/src/file-download/DownloadFile.ts b/packages/jsActions/mobile-resources-native/src/file-download/DownloadFile.ts index 2eadc1a1f..93216aefd 100644 --- a/packages/jsActions/mobile-resources-native/src/file-download/DownloadFile.ts +++ b/packages/jsActions/mobile-resources-native/src/file-download/DownloadFile.ts @@ -69,7 +69,7 @@ export async function DownloadFile(file: mendix.lib.MxObject, openWithOS: boolea const fileName = file.get("Name") as string; const sanitizedFileName = sanitizeFileName(fileName); const baseDir = Platform.OS === "ios" ? dirs.DocumentDir : dirs.DownloadDir; - const filePath = mx.data.getDocumentUrl(file.getGuid(), Number(file.get("changedDate"))); + const filePath = await mx.data.getDocumentUrl(file.getGuid(), Number(file.get("changedDate"))); let accessiblePath; if (Platform.OS === "ios") { diff --git a/packages/jsActions/mobile-resources-native/src/platform/PlaySound.ts b/packages/jsActions/mobile-resources-native/src/platform/PlaySound.ts index 59bd98c54..67f64adfc 100644 --- a/packages/jsActions/mobile-resources-native/src/platform/PlaySound.ts +++ b/packages/jsActions/mobile-resources-native/src/platform/PlaySound.ts @@ -32,7 +32,7 @@ export async function PlaySound(audioFile?: mendix.lib.MxObject): Promise const guid = audioFile.getGuid(); const changedDate = audioFile.get("changedDate") as number; - const url = mx.data.getDocumentUrl(guid, changedDate); + const url = await mx.data.getDocumentUrl(guid, changedDate); try { // Initialize the player if it hasn't been set up yet