Where can I find the phonegap.js for browser testing ?

  • 5
  • Question
  • Updated 7 years ago
  • Answered
In the docs it is instructed to remove the phonegap.js from the html since it will be replaced in the build.
But where can I find this file in the first place ?
I need it to abstract the request and geolocalisation function of the browser while testing the app in browser, it is a requirement right ?
The docs is very vague on this point if you never used phonegap without phonegap build before...
Photo of Maxime Dehaye

Maxime Dehaye

  • 3 Posts
  • 0 Reply Likes
  • confused

Posted 7 years ago

  • 5
Photo of Mario

Mario, Champion

  • 120 Posts
  • 17 Reply Likes
Hi

You don't need phonegap.js while developing in your browser, because it won't work without the API.

I suggest to write some simple JavaScript modules to simulate the API calls locally.

Example:
if (!navigator.notification) {

// no notification API; development inside browser
alert('title:\n' + title +
'\n\nmessage:\n' + message +
'\n\nbuttonLabel:\n' + buttonLabel +
'\n\ncallback:\n' + callback);
if (callback) callback();
} else {
// use PhoneGap API
navigator.notification.alert(message, callback, title, buttonLabel);
}

Something like that. I hope that is what you asked for and what you need. :-)

Have fun!
Photo of Maxime Dehaye

Maxime Dehaye

  • 3 Posts
  • 0 Reply Likes
OK so there's no way for me to "emulate" the phoneGap API in the browser ?
I have to develop my app in the browser while adding code for phonegap too and test it on my device at the end ?
Is that how you do it ?
Photo of Mario

Mario, Champion

  • 120 Posts
  • 17 Reply Likes
You can use the Ripple Emulator:
http://emulate.phonegap.com/

It simulates the API in your browser.

But I don't really like it. I am more productive when I write my own modules with debug fallbacks and simulates for testing.
Photo of Maxime Dehaye

Maxime Dehaye

  • 3 Posts
  • 0 Reply Likes
Ok I see
Thank you very much for these infos, I was thinkg about doing exactly what you're doing but it seemed weird and add a lot of work...
I hope someone come up with an phonegap "emulator" for browse real soon =)
The doc is really not clear on these points... =/
Photo of Hyginus Ugwumba

Hyginus Ugwumba

  • 1206 Posts
  • 42 Reply Likes
Hi Maxime,

You need to download from www.phonegap.com.

After completing your download, locate the file as below.

Goto > lib > ios > CordovaLib > cordova.js

Thanks
Hyginus
Photo of Amir

Amir

  • 8261 Posts
  • 263 Reply Likes
The above comment means for finding cordova.js

However it is not required for building with Build service.

Thanks
Photo of Mario

Mario, Champion

  • 120 Posts
  • 17 Reply Likes
Hi Hyginus

thank you for pointing to the file.

What is the benefit of using cordova.js for local development in a browser? (Especially, when using PhoneGap Build, I don't get it.)

cordova.js requires some other stuff, like cordova_plugins.json. If it is available, I get the following log messages:
deviceready has not fired after 5 seconds. cordova.js:5977

Channel not fired: onNativeReady cordova.js:5970
Channel not fired: onCordovaReady cordova.js:5970
Channel not fired: onCordovaConnectionReady


That's no surprise, as we have no device and no wrapped webview. So, why are we doing this? :-)

Thx
Mario
Photo of Amir

Amir

  • 8261 Posts
  • 263 Reply Likes
Topic more then a week old. Closing

This conversation is no longer open for comments or replies.