Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PhoneGap By Example

You're reading from   PhoneGap By Example Use PhoneGap to apply web development skills and learn variety of cross-platform mobile applications

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher
ISBN-13 9781785285318
Length 368 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. Installing and Configuring PhoneGap FREE CHAPTER 2. Setting Up a Project Structure with Sencha Touch 3. Easy Work with Device – Your First PhoneGap Application "Travelly" 4. Integrating the Travelly Application with Custom Service 5. Crazy Bubbles - Your First HTML5 Mobile Game 6. Share Your Crazy Bubbles Game Result on Social Networks 7. Building a Real-time Communication Application – Pumpidu 8. Building "Imaginary" – An Application with Instagram-like Image Filters 9. Testing the PhoneGap Application 10. Releasing and Maintaining the Application Index

The config.xml structure

Before proceeding to consider the specific settings for each mobile platform, let's look at the common configuration file config.xml. This file contains very important information on setting up our future applications.

By default, our config.xml file has the following contents:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.cybind.travelly" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Travelly</name>
    <description>
      A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" 
    href="http://cordova.io">
      Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
</widget>

Where:

  • Widget: It's ID attribute provides the app's reverse-domain identifier, and the version provides its full version number.

    Tip

    Reverse domain name notation is a naming convention for the components, packages, and types used by a programming language, system, or framework.

  • Name: This specifies the app's formal name as it appears on the device's home screen and within app-store interfaces.
  • Description and author: This specifies metadata and contact information that may appear within app-store listings.
  • Content: This optional element defines the app's starting page in the top-level web assets directory.
  • Access: This defines the set of external domains the app is allowed to communicate with. In our case, we allow it to access any server.

Furthermore, there can be other options presented. Usually, they are added under the tag access. These elements are preference and feature.

Preference items can be global and multiplatform.

For example, the following two settings are global and apply to all supported platforms:

<preference name="Fullscreen" value="true" />
<preference name="Orientation" value="landscape" />

Where:

  • Fullscreen allows you to hide the status bar at the top of the screen
  • Orientation allows you to lock orientation and prevent the interface from rotating in response to changes in orientation

The following two settings apply to multiple platforms, but not all:

<preference name="TopActivityIndicator" value="gray" />
<preference name="AutoHideSplashScreen" value="false" />

Where:

  • TopActivityIndicator sets the color of the Activity Indicator
  • AutoHideSplashScreen specifies whether to hide the splash screen automatically or allow the programmer to do it in code

In this case, it is not necessary to add feature elements manually, because in the initial stage, we will use the cross-platform workflow, where we will use the command CLI plugin to add the device API. However, when we move to fine-tuning of each platform, we will add the feature elements, as shown in this example:

  <feature name="Device">
    <param name="ios-package" value="CDVDevice" />
  </feature>

  <feature name="Device">
    <param name="android-package" value="org.apache.cordova.device.Device" />
  </feature>
You have been reading a chapter from
PhoneGap By Example
Published in: Aug 2015
Publisher:
ISBN-13: 9781785285318
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime