Since there are several similar Cordova plugins, I think itās just an error in the version number or plugin name : meteor add cordova:cordova-plugin-camera-preview@0.9.0 works, for example.
The addition of the package isnāt the problem. The app gives an error that CameraPreview is not defined. If some could provide the correct import statement I think it would fix my problem.
cordova-camera-preview lists no main file and has no index.js, so it canāt be directly requiredā¦It may however contain internal files that you can require manually.
The 1.0.6 version mentioned in your first post and installed with meteor add cordova: canāt be found in the registry, only on Npm. Its author mentions itās just a test forked from the original plugin - which is still at 0.9.0, can be installed and works pretty well out of the box (at least on iOS, except for some background thread warnings in Xcode). No need to import, btw : just call CameraPreview and it works.
This is weird, I just pasted the exact same code in Safariās console and it works on any connected iOS device. Do you get this error with version 0.9.0, installed with meteor add ?
I took a look and saw that the plugin has been installed with meteor npm install, not meteor add cordova:.
Using the same project after running meteor add cordova:cordova-plugin-camera-preview@0.9.0, which will add/update a cordova-plugins file inside the .meteor directory, do you still get the error on Android when calling CameraPreview directly, without any import ?
Thereās another important thing to mention about this plugin : the version on Npm, which is also the one grabbed by Meteor when performing meteor add cordova:, is presently outdated compared to the master branch on Github.
Best way to use the most recent version (which solves a problem with CameraPreview.stop() taking several seconds to execute while blocking the UI, as stated in this issue and this pull request) is to replace any version number (in this case 0.9.0) with the GitHub repository url. The line in your .cordova-plugins file should look like this :
Hello,
I reactivate this topic because i have exactly the same issue.
I tried all the previous solutions without success.
Does anyone had any luck, recently, here?
The expected behaviour:
I can access CameraPreview
The current behaviour:
CameraPreview is undefined
letās try this (if you didnāt). If you use React just add this at the top, outside your functional component (or class), after your imports. In other frameworks you my try something similar of just initialize the value of CameraPreview = window.CameraPreview in your client startup file and keep it global (initialize without const, let or var).
If this works, you can let me know if you need anything else about this plugin. I can see I used it in the past, with React, in a couple of projects.
Thanks for your answer.
The problem seems to be elsewere as window.CameraPreview is unknown. It seems I canāt manage to get this plugin running on my project.
The current version of Meteor is 2.9.1 and the plugin in meteor list