Creating basic apps with PhoneGap - javascript

I installed PhoneGap with nodejs, and I sent the create command to create a folder with the basic files needed for the first app. When I open the index.html file there is a script tag that points to a file called phonegap.js. The problem is that this does not exist in the folder, where is it? The app is running if built without that file or not?
That is my folder:
My object is to create a basic app working.
Thanks.

The file is created when you add a platform to your project (because its content is different for each platform)
For example, for an android project it should be in platforms/android/assets/www/phone gap.js.

Related

Cordova plugins not working when using Framework7

I am making a Cordova app using Framework7 for iOS/Android. I'm trying to add the social sharing plugin and the barcode scanner plugin but the plugin functions can not be called. However when I made a Cordova app with plain HTML and JS (without Framework7) the plugins would work. Is there anything I have to modify on the Framework7 side to enable these Cordova plugins to work?
cordova.js file need not be there in your project root directory. Everytime you do a particular platform build, it gets automatically created in the platform build's project root directory.
For instance, if you build android platform using 'cordova build android' command, the cordova.js file will be generated under 'platforms\android\assets\www' folder. This js file is very much required to use any of the cordova plugins as it is the one which is responsible for triggering 'onDeviceReady' event once the cordova is ready and all plugins are loaded. You can also have a look at the generated file once to get more info on the same. Hope it helps.

Replacing existing ios app with a PhoneGap version

I've been getting mixed reviews recently on one of my apps so I've been working on a HTML5 phonegap replacement.
Do I just have to match the bundle ID up with the existing app?
I have tried to create a new app using the following command phonegap create "CSCS Revision" --id "<my bundle ID>" --name "<my app name>". However, I have a problem, <my bundle ID> contains a hyphen, and phonegap tells me that it's an invalid character, is there a way to override this?
The next thing I tried was creating the app and then changing the bundle ID. This seemed to work OK, but when I copied over the contents of my www directory from the other app it seems that some of the javascript files aren't included properly in the HTML.
I have one file called data.js that just has a big array in it, but it seems that the array can't be accessed in the newly created app despite it working in the other app which is a direct copy.
OK, so I was being a little slow on the uptake.
The way to get this submitted to Apple is to give it an id that is valid by phonegap in the command phonegap create "CSCS Revision" --id "<my bundle ID>" --name "<my app name>"
Add your javascript and html to the www directory, however unlike myself don't make a change before doing the copy that makes the javascript crash.
Run the command phonegap build ios. Then change the Bundle ID in the project settings. At this point you can then archive the project and submit it to the App Store.
One problem I had was missing icons. I like to use this website to make all of my icons of the required sizes. I then copied the icon portion of the config.xml file from this app into my config.xml and reran phonegap build ios (if you do this you'll have to change the bundle ID again in xcode before submitting to the store).

Cordova saving a file within the www folder

I am currently creating a Cordova app to save files and read files. I ahve successfully managed to code it up so that it reads a file from the device (or creates it if it does not exist) and then write to that file.
The problem I am having is that it is saving the file to the root of the device. I added in a getDirectory method to create a new directory under the root where the file can sit and this is working but ideally I would like to save the file within the www folder of my Cordova app. Is this possible? Also is there any way of making sure the user is unable to write to this file?
The www folder is in readonly mode. You can't write anything in it.
Cordova plugin file documentation explain this.

Phonegap Android HTML wont update

I am trying to upload some code html and javascript code into phonegap to develop this app however when I update the files the program still runs the old code as to what was in the html file before. I have even started a new project and it will not change the old index.html image even though the code behind it is different. I'm really confused as to why this is and I was wondering what I could do to solve this. I even searched through the workspace index.html file and it is the correct file that I want in there but upon running it i am given the same your device is ready hello world. I checked the location of the files and everything is correct. It is very confusing. I am using eclipse by the way not phonegap build if that helps.
you need to build your project again.
cordova build android
But make sure you edit your files in www folder in parent folder.
Make sure you are updating the WWW file in the root Phonegap folder. Then you can run the command:
$ cordova build
or
$ phonegap build

Problems with adding multiple html files on Mosync

i'm new to Mosync and i'm trying to create an HTML5/Javascript project. The IDE generates a main.cpp file and an index.html file.
The main.cpp file contains a reference for the index.html file; i've already tried creating a new html file inside the same folder where the generated index.html file is and changed the reference in the main.cpp file to call the file that i've just created but it gives me an error that says the file cannot be found.
I've even tried removing all the code in the generate index.html file and running it and the results still shows all the deleted code from the index.html file.
My question would be how do i add multiple html files when creating a MoSync project?
It should work to do what you are doing, this could be a bug. Can you provide some details about which version of MoSync you are using, and which platform?
You should be able to have any html file in the folder LocalFiles in a MoSync project, and then just pass the file name to showPage in main.cpp, just as you are doing.
Perhaps the project is not rebuild properly? Try to right-click on the project in Eclipse, then select Rebuild. Are you on iOS or Android? How do you transfer the app to the device?
As Mikael mentioned also, I think it is an IDE bug, I tried refreshing/rebuilding the project and it worked fine. Sometimes eclipse does not detect file changes that come from other editors so it ignores them.

Categories

Resources