Closed webnologie closed 5 years ago
Hello Chris!
Thank you for your Reply!
Problem is on real device: ios 9.x and also ios 12
Iphone and also ipad
PS C:\Users\offic\OneDrive\4_Code\Phonegap\quickjob3> framework7 cordova platform ls
Installed platforms:
android 7.0.0
ios 4.5.5
thank you emanuel
Von: Christy Thomas Alex notifications@github.com Gesendet: Montag, 8. Juli 2019 13:17 An: NeutrinosPlatform/cordova-plugin-document-scanner cordova-plugin-document-scanner@noreply.github.com Cc: webnologie office@webnologie.at; Mention mention@noreply.github.com Betreff: Re: [NeutrinosPlatform/cordova-plugin-document-scanner] iOS: Imageuri could not open (#56)
Hey @webnologie https://github.com/webnologie
Thanks for raising an issue. Could you please also provide the following information so I can look into this?
Cheers and have a nice day! Chris https://github.com/ChrisTomAlx Neutrinos http://www.neutrinos.co/
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NeutrinosPlatform/cordova-plugin-document-scanner/issues/56?email_source=notifications&email_token=AFCCJS6WSD6EPUGY5IDBLHLP6MO2HA5CNFSM4H6YRMUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZMYUEA#issuecomment-509184528 , or mute the thread https://github.com/notifications/unsubscribe-auth/AFCCJSZZGDIUE6HQHNJZJA3P6MO2HANCNFSM4H6YRMUA .
Hey @webnologie
Would it be possible for you to zip a sample project with this issue and send it over so I can check it out on my side. You can use firefox send.
Also could you provide the version of the plugin you are using?
Hello i just made an sample project:
https://send.firefox.com/download/d4a36487a971dc8e/#j-Kk7-BjRMyNtIOfJytWgw
please open with xcode the xcworkspace project file…
thank you
Von: Christy Thomas Alex notifications@github.com Gesendet: Montag, 8. Juli 2019 14:12 An: NeutrinosPlatform/cordova-plugin-document-scanner cordova-plugin-document-scanner@noreply.github.com Cc: webnologie office@webnologie.at; Mention mention@noreply.github.com Betreff: Re: [NeutrinosPlatform/cordova-plugin-document-scanner] iOS: Imageuri could not open (#56)
Hey @webnologie https://github.com/webnologie
Would it be possible for you to zip a sample project with this issue and send it over so I can check it out on my side. You can use firefox send https://send.firefox.com/ .
Cheers Chris https://github.com/ChrisTomAlx Neutrinos http://www.neutrinos.co/
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NeutrinosPlatform/cordova-plugin-document-scanner/issues/56?email_source=notifications&email_token=AFCCJS7NJGCX7NPNQ7YTU63P6MVH3A5CNFSM4H6YRMUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZM4MAY#issuecomment-509199875 , or mute the thread https://github.com/notifications/unsubscribe-auth/AFCCJS4Z3OG7473L5QDYRR3P6MVH3ANCNFSM4H6YRMUA .
You are great. Did you see the problem. Greetings from Austria
Mit freundlichen Grüßen, Emanuel Hölzl
On Mon, Jul 8, 2019 at 8:21 PM +0200, "Christy Thomas Alex" notifications@github.com wrote:
Thanks for the share @webnologie.
I will see what I can find and get back to you as soon as I can.
Cheers
Chris
Neutrinos
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
So I figured out what the problem is, This is being caused by wkwebview.. Sigh..
So the issue is that wkwebview doesn't allow you to load images the traditional way. I was playing around with some fixes that did not pan out. There is one more thing that I am going to try. If you get the time you could try it on your end as well (It is a JavaScript only solution so there is no native code involved). Here you go :- https://www.construct.net/en/blogs/ashleys-blog-2/hacking-something-useful-932
Hello Chris!
Thank you for your reply.
I already tried to load the image-data via XHR (AJAX) to get the Array Buffer.
Then I converted this stream to a Image-Blob… On Android it will work but also not on ios.
Hmm, I cant find a solution.
Br, emanuel
Von: Christy Thomas Alex notifications@github.com Gesendet: Dienstag, 9. Juli 2019 19:53 An: NeutrinosPlatform/cordova-plugin-document-scanner cordova-plugin-document-scanner@noreply.github.com Cc: webnologie office@webnologie.at; Mention mention@noreply.github.com Betreff: Re: [NeutrinosPlatform/cordova-plugin-document-scanner] iOS: Imageuri could not open (#56)
So I figured out what the problem is, This is being caused by wkwebview.. Sigh..
So the issue is that wkwebview doesn't allow you to load images the traditional way. I was playing around with some fixes that did not pan out. There is one more thing that I am going to try. If you get the time you could try it on your end as well (It is a JavaScript only solution so there is no native code involved). Here you go :- https://www.construct.net/en/blogs/ashleys-blog-2/hacking-something-useful-932
Cheers Chris https://github.com/ChrisTomAlx Neutrinos http://www.neutrinos.co/
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NeutrinosPlatform/cordova-plugin-document-scanner/issues/56?email_source=notifications&email_token=AFCCJS2S6FTTGZSWSVNEXCTP6TF7TA5CNFSM4H6YRMUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZRAWTA#issuecomment-509741900 , or mute the thread https://github.com/notifications/unsubscribe-auth/AFCCJS5FVYWGHKLY2XPFV33P6TF7TANCNFSM4H6YRMUA .
So I have a workaround for you. Until WkWebView has fixed these issues we will have to do as below.
cordova plugin add cordova-plugin-file
scan.scanDoc(onSuccess, onFail, { sourceType: 1, fileName: "image" });
function onSuccess(imageURI) { console.log(imageURI); // Convert the uri to base 64 using cordova-plugin-file getFileContentAsBase64(imageURI, function (base64Image) { // Use base 64 to set the src document.getElementById("myImage").src = base64Image; }); }
function onFail(message) { alert('Failed because: ' + message); }
function getFileContentAsBase64(path, callback) { window.resolveLocalFileSystemURL(path, gotFile, fail);
function fail(e) {
alert('Cannot find requested file');
}
function gotFile(fileEntry) {
fileEntry.file(function (file) {
var reader = new FileReader();
reader.onloadend = function (e) {
var content = this.result;
callback(content);
};
reader.readAsDataURL(file);
});
}
}
Note :- Basically what we are doing is natively converting the file URI to base64 then getting this base64 back to set the img src. This might cause your app to take a small performance hit. Also you might have to use progress spinners so that the user knows to wait for a response.
PS :- I have tested this code only with iOS. Also this is only required for iOS. So you could improve performance in Android devices by running this code only if platform is iOS. But if you choose to test this code on Android as well, please let me know if it works out correctly as I haven't tested on Android.
Let me know if you are running into any other troubles. Also do close the issue if this solved your problem
Thanks and Cheers from India :)
[Chris](https://github.com/ChrisTomAlx)
[Neutrinos](http://www.neutrinos.co/)
Hello Chris!
Thank you very much!! It will work on ios and android. Performance is still good.
Please send me your paypal-address. I wanna send you a little something!
This was great support. Maybe you can also send me your contact-infos – maybe I have something for you in future – if you are interested.
Greetings from austria!
Von: Christy Thomas Alex notifications@github.com Gesendet: Mittwoch, 10. Juli 2019 10:00 An: NeutrinosPlatform/cordova-plugin-document-scanner cordova-plugin-document-scanner@noreply.github.com Cc: webnologie office@webnologie.at; Mention mention@noreply.github.com Betreff: Re: [NeutrinosPlatform/cordova-plugin-document-scanner] iOS: WKWebView - Image URI could not open (#56)
So I have a workaround for you. Until WkWebView has fixed these issues we will have to do as below.
Firstly add cordova-plugin-file to your project as shown below (for cordova projects) :-
cordova plugin add cordova-plugin-file
Then you can use the scanner plugin in this way :-
scan.scanDoc(onSuccess, onFail, { sourceType: 1, fileName: "image" });
function onSuccess(imageURI) { console.log(imageURI); // Convert the uri to base 64 using cordova-plugin-file getFileContentAsBase64(imageURI, function (base64Image) { // Use base 64 to set the src document.getElementById("myImage").src = base64Image; }); }
function onFail(message) { alert('Failed because: ' + message); }
function getFileContentAsBase64(path, callback) { window.resolveLocalFileSystemURL(path, gotFile, fail);
function fail(e) { alert('Cannot found requested file'); }
function gotFile(fileEntry) { fileEntry.file(function (file) { var reader = new FileReader(); reader.onloadend = function (e) { var content = this.result; callback(content); }; reader.readAsDataURL(file); }); } }
Note :- Basically what we are doing is natively converting the file URI to base64 then getting this base64 back to set the img src. This might cause your app to take a small performance hit. Also you might have to use progress spinners so that the user knows to wait for a response.
PS :- I have tested this code only with iOS. Also this is only required for iOS. So you could improve performance in Android devices by running this code only if platform is iOS. But if you choose to test this code on Android as well, please let me know if it works out correctly as I haven't tested on Android.
Let me know if you are running into any other troubles. Also do close the issue if this solved your problem
Thanks and Cheers from India :) Chris https://github.com/ChrisTomAlx Neutrinos http://www.neutrinos.co/
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NeutrinosPlatform/cordova-plugin-document-scanner/issues/56?email_source=notifications&email_token=AFCCJS4UZRW6UGIY6ZEGQULP6WJG7A5CNFSM4H6YRMUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZSUTRI#issuecomment-509954501 , or mute the thread https://github.com/notifications/unsubscribe-auth/AFCCJS5D2WH5LYUIJUVJRVLP6WJG7ANCNFSM4H6YRMUA .
Hey @webnologie
Please send me your paypal-address. I wanna send you a little something!
Thanks a ton for the offer but for now your gratitude and your perseverance to stick with this issue till it was fixed is all that is required. Future users that run into this issue now have access to an easy workaround, thanks to you :)
This was great support. Maybe you can also send me your contact-infos – maybe I have something for you in future – if you are interested.
Definitely, you can get in touch with me using the following E-mail ID's Work (Neutrinos) :- christy.alex@neutrinos.co Company (Neutrinos) :- ideas@neutrinos.co Personal :- christythomasalex@gmail.com
Closing this issue. Please feel free to open another if you need help.
Hello! first i wanna thank you for your plugin! but i have one problem with ios. if i receive the imageuri (file:///var/...) i cant open the file. i tried it directly with <image src... and also to get the stream buffer and generate a blob. andorid, no problem but ios will not work.
maybe you can help me. thank you!