-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scan object undefined in ionic 2 #17
Comments
Hi, Sorry about the delayed response. I do not have much experience with Ionic 2, but a quick search gave me this answer. So you can use the scanner as shown below :-
Try |
Hi,
console.log: NativeAudio |
Here is another solution . The 8th or 9th comment has this answer. I have pasted the answer below, but I would suggest going through the link. Maybe you will find other answers if this doesn't work.
Try this as well :-
|
I have tried everything. but nothing works.. when i do cordova plugins list. i can see the plugin name in the list. When i tried to import the plugin it says module not found.. Do i have to install something else before adding this plugin? :( |
Have you tried on a device? I was having errors in browser but it worked in my android device. Here are the steps I followed :-
Let me know if you are still having trouble. |
Hi, |
Try this instead. The change in the below code is that the
To get the following code to work you must define an image tag with id
|
So i am able to get it working with the selection of image from gallery. but it still does not work when i take the picture from camera. Here is the working code.
This works as expected. But when i the change it to |
I am using the below code and I am not running into any problems. Please check in android studio. Maybe the stack trace from that might help.
Try commenting out the HTML parts or try using the code I am using and check if it works. |
ionic create 3 files when when a page is created.
|
The problem is exactly the same as described here |
Have you tried this solution?
I am not able to recreate your situation on my end. Also fyi it seems like you used the url markup wrong. It would be nice if you could edit it, so in the future people could directly click the link. EDIT :- I actually could edit it myself. I hope you don't mind :) |
The flag "Dont keep activities" is turned off by default. I am attaching the code which i am using and you can try that on ur phone. btw i am testing the app on Samsung Galaxy s8 with android 8.0.0. what device are you testing on? |
I have tried to look at the logs from the device. Seems like its a problem of permissions or something and not with the plugin itself. Here is the exception
|
I am testing on Samsung S7 Edge with Android 7.0. Could you send me your entire ionic project? Or create a blank one from scratch with just this plugin and I will test it out. |
Here is a blank project with the plugin installed. |
What I meant was a blank project that uses this plugin maybe on click or on platform ready. Would love it if you could send a blank project that you have build on your side and ran into to problems, then I can directly run on my device and see the issue first hand. Anyhow, I will check the code I shared with my android 8.0 device and get back. If it doesn't work with my android 8.0 device then a clear path opens up as to what might be the problem. I will let you know once it is done. |
I built the app for android 7 and it worked.!!! 👍 .. so clearly there is some issue with the scanner plugin on android 8. |
Okay so I found a temporary hotfix which you can use now.
As you can see I added that bit of code below the |
Hi, I solved the error application auto restarting after take picture from camera by using plugin "cordova-plugin-background-mode" this plugin can prevent the app from going to sleep while in background. |
@duyetnk So you are able to use the camera functionality of this plugin in Android 8.0+ without making changes to config.xml just by using the cordova-plugin-background-mode? If so then thank you for sharing your solution with us :) |
i just run in Android 7.0 device, not 8.0 |
@duyetnk There are no problems with android 7.0 as far as I have tested it. Android 8.0 was where I was having the problem and thus I suggested the hotfix to change config.xml. I tested it with Android 8.0 and I don't think it fixed it, although it is possible I am not using the plugin cordova-plugin-background-mode correctly. Would you be kind enough to either test your project on an Android 8.0 device or send me a project where this solution of yours has been implemented so I can directly run it on my Android 8.0 device to test it? |
@ChrisTomAlx Currently i don't have Android 8.0 device so i can't test it For cordova-plugin-background-mode plugin i just use enable() method, nothing special. |
Yea that is what I did. Still couldn't to get it to work on Android 8.0.
I highly doubt this will work, but I will try. The real problem is that the scan library is taking a uri from the plugin and working on it, then sending the image back to the plugin which then sends it to the cordova app. In Android 8.0, they made major security updates which changed the way files and uris can be shared and thus the issue with Android 8.0 alone. This is why
No worries, If you do get a chance to test it, please let me know if it worked or not. Cheers and thank you for taking an interest in solving this issue :) |
I agree with chris here.. what i have discovered is that on android 8, problem is about the new security updates and not about the app going to background thingy. With some configuration in the config.xml i was able to stop the crashing of app, and it could select/take the picture, but it crashed while saving the picture. After that point i just turned back to 25 sdkversion :) |
… play store security
…dated support for new versions of android
# Conflicts: # plugin.xml
Hi,
I am trying to use this plugin within my ionic 2 app. but i cannot access scan object in my device ready event. Here is my code.
constructor(public nav: NavController, private camera: Camera, private platform : Platform) { this.platform.ready().then((readySource) => { console.log("Platform ready from", readySource); // Platform now ready, execute any required native code console.log(scan); }); }
and this is the error message i am getting.
Error: Uncaught (in promise): ReferenceError: scan is not defined ReferenceError: scan is not defined at http://localhost:8100/build/main.js:652:25 at t.invoke (http://localhost:8100/build/polyfills.js:3:14976) at Object.onInvoke (http://localhost:8100/build/vendor.js:5134:33) at t.invoke (http://localhost:8100/build/polyfills.js:3:14916) at r.run (http://localhost:8100/build/polyfills.js:3:10143) at http://localhost:8100/build/polyfills.js:3:20242 at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15660) at Object.onInvokeTask (http://localhost:8100/build/vendor.js:5125:33) at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15581) at r.runTask (http://localhost:8100/build/polyfills.js:3:10834) at c (http://localhost:8100/build/polyfills.js:3:19752) at http://localhost:8100/build/polyfills.js:3:20273 at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15660) at Object.onInvokeTask (http://localhost:8100/build/vendor.js:5125:33) at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15581) at r.runTask (http://localhost:8100/build/polyfills.js:3:10834) at o (http://localhost:8100/build/polyfills.js:3:7894)
Any help regarding this issue?
The text was updated successfully, but these errors were encountered: