From 4660b26d6251da8e9264e50c1ae76a723a958ce3 Mon Sep 17 00:00:00 2001 From: Pawan Koshti Date: Mon, 16 Sep 2024 12:34:23 +0530 Subject: [PATCH] Tab-product inspection fixed for android and IOS --- .../Views/Home/ScanProduct.cshtml | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/samples/tab-product-inspection/csharp/ProductInspection/Views/Home/ScanProduct.cshtml b/samples/tab-product-inspection/csharp/ProductInspection/Views/Home/ScanProduct.cshtml index 412dfff68e..3745e2bf37 100644 --- a/samples/tab-product-inspection/csharp/ProductInspection/Views/Home/ScanProduct.cshtml +++ b/samples/tab-product-inspection/csharp/ProductInspection/Views/Home/ScanProduct.cshtml @@ -23,7 +23,7 @@ let productName; let image = ""; - // Method to scan barcode + //Method to scan barcode function scanBarCode() { var config = { timeOutIntervalInSec: 30 @@ -67,24 +67,37 @@ }, config); } - // Method to capture product image - function captureImage() { + //Method to capture product image + function selectMedia() { microsoftTeams.app.initialize().then(() => { + + var imageProp = { + sources: [microsoftTeams.media.Source.Camera, microsoftTeams.media.Source.Gallery], + startMode: microsoftTeams.media.CameraStartMode.Photo, + ink: false, + cameraSwitcher: false, + textSticker: false, + enableFilter: true + }; - // Method to ask for image capture permission and then capture image - microsoftTeams.media.captureImage((error, files) => { - // If there's any error, an alert shows the error message/code + var mediaInput = { + mediaType: microsoftTeams.media.MediaType.Image, + maxMediaCount: 1, + imageProps: imageProp + }; + + microsoftTeams.media.selectMedia(mediaInput, function (error, attachments) { if (error) { if (error.message) { alert(" ErrorCode: " + error.errorCode + error.message); } else { alert(" ErrorCode: " + error.errorCode); } - } else if (files) { - image = files[0].content; - $("#productImg").attr("src", "data:image/png;base64," + image); - $("#productStatus").show(); - } + } else if (attachments) { + image = attachments[0]; + $("#productImg").attr("src", "data:image/png;base64," + image.preview); + $("#productStatus").show(); + } }); }); } @@ -93,7 +106,7 @@ var productStatus = status ? "Approved" : "Rejected"; const formData = new FormData(); formData.append('productId', productId); - formData.append('image', "data:image/png;base64," + image); + formData.append('image', "data:image/png;base64," + image.preview); formData.append('status', productStatus); $("#productStatus").hide(); $("#captureImage").hide(); @@ -125,7 +138,7 @@
- +