Cordova Flashlight plugin problem

  • 1
  • Problem
  • Updated 5 years ago
Hello! I have a problem with Flashlight plugin https://build.phonegap.com/plugins/294
It does not work and I do`nt know why, I tried different solutions, but it still not work. And I have strange error in Firefox Firebug:
ReferenceError: cordova is not defined
cordova.addConstructor(Flashlight.install);
How can I fix it? Thanks.
Photo of Vladislav Gasan

Vladislav Gasan

  • 13 Posts
  • 0 Reply Likes

Posted 7 years ago

  • 1
Photo of Eddy Verbruggen

Eddy Verbruggen, Champion

  • 375 Posts
  • 86 Reply Likes
Hi,

You cant run cordova in firefox. Can we have a look at your code to assist any further?
Photo of Vladislav Gasan

Vladislav Gasan

  • 13 Posts
  • 0 Reply Likes
I know that I can`t but maybe this is a way to find source of the problem,

Here is the source code https://drive.google.com/file/d/0B3P5...

Please take alook on it, I hope you find solution
Photo of Eddy Verbruggen

Eddy Verbruggen, Champion

  • 375 Posts
  • 86 Reply Likes
I assume you are using Phonegap Build for your project. In that case, please follow these steps: https://github.com/EddyVerbruggen/Fla...

The difference is, you include the flashlight.js file in your code, but you need to add

<script src="js/plugins/Flashlight.js"></script> after phonegap.js.
Photo of Vladislav Gasan

Vladislav Gasan

  • 13 Posts
  • 0 Reply Likes
Oh, I thought that path is not critical, I will try to rebuild app. Thanks.
Photo of Eddy Verbruggen

Eddy Verbruggen, Champion

  • 375 Posts
  • 86 Reply Likes
Indeed, add the script reference, but don't include the actual js file (same procedure as phonegap.js)
Photo of Vladislav Gasan

Vladislav Gasan

  • 13 Posts
  • 0 Reply Likes
Okay. I will try. Thanks.
Photo of Vladislav Gasan

Vladislav Gasan

  • 13 Posts
  • 0 Reply Likes
Unfortunately it still now works...
Photo of Vladislav Gasan

Vladislav Gasan

  • 13 Posts
  • 0 Reply Likes
I wrote and don`t include it, tried to write inline javascript but there is no result. I don`t know where is the problem. Maybe you can build app and check what`s wrong?
Photo of Eddy Verbruggen

Eddy Verbruggen, Champion

  • 375 Posts
  • 86 Reply Likes
Can you update the Google Drive files?
Photo of Vladislav Gasan

Vladislav Gasan

  • 13 Posts
  • 0 Reply Likes
Photo of Vladislav Gasan

Vladislav Gasan

  • 13 Posts
  • 0 Reply Likes
I tried and but no one works
Photo of Vladislav Gasan

Vladislav Gasan

  • 13 Posts
  • 0 Reply Likes
I tried script src="js/plugins/Flashlight.js"and script src="Flashlight.js" but no one works
Photo of Eddy Verbruggen

Eddy Verbruggen, Champion

  • 375 Posts
  • 86 Reply Likes
Use the first option.
And place it AFTER phonegap.js in your index.html please.
Photo of Vladislav Gasan

Vladislav Gasan

  • 13 Posts
  • 0 Reply Likes
I swaped phonegap.js and Flashlight.js, now it works! It`s was my inattentivness. Thank you Eddy!
Photo of Vladislav Gasan

Vladislav Gasan

  • 13 Posts
  • 0 Reply Likes
I built my app, it works fine but hava a little bug on Android. When I simply open my app and turn on/off flashlight it works fine, then press back button, app is closing (or not?), open app again, and now when I press "On" button my flashlight don`t work! It begin to work when I press "On" 4-10 times, number of presses is different every time. Do you know what it may be?

P.S. When I clear memory app works fine
Photo of Zahir

Zahir

  • 3500 Posts
  • 40 Reply Likes
Hi Vladislav,

Would you mind updating us on your current progress?
Thanks.
Photo of Vladislav Gasan

Vladislav Gasan

  • 13 Posts
  • 0 Reply Likes
Hello Zahir,

I still have problems with delay on clicking

Regards
Photo of Eddy Verbruggen

Eddy Verbruggen, Champion

  • 375 Posts
  • 86 Reply Likes
Can you give the new 1.3 version a try?
https://build.phonegap.com/plugins/443
Photo of Harry Chauhan

Harry Chauhan

  • 1 Post
  • 0 Reply Likes
I am using the Flashlight plugin. It works but the light turns on only for a second. I tried to increase the time in setTimeout also but no luck. Any ideas?