menu

Wednesday 26 February 2014

create a mobile app in php

How to start?

Development of a complex iPFaces application is really simple because the simulation mode can be used. This mode is capable of transfering XML content to a HTML page, which can be displayed in a web browser. It is a helpful tool for developers who can see their iPFaces application in the browser window and they do not need a real iPhone device for main development.
Developers can build and deploy an application to the application server and the browser will show them the GUI which is almost the same as a screen in an iPhone application. There is a difference in the GPS elements. A GPS field is working in a browser only as text field that can be filled by user and GPS coordinates will be submitted. The GPS field is hidden on mobile devices, because the location of the device is detected without interaction with the user.

Hello world example

To use PHP iPFaces library, just include “ipfaces-php-lib-1.1.php” file, construct the component tree and call “render()” method on the component form.
<?php
   require "path/to/ipfaces/library/ipfaces-php-1.1.php";

   $ipf_form = new IPFForm("form1", "Form");
   $ipf_screen = $ipf_form->addScreen("Hello World Application", "screen1");
   $ipf_screen->addLabel("Hello World!");
   $ipf_form->render();
?>
 
Hello world app on the iPhone device and in a web browser

Use of location service

To obtain a user location from a mobile device use the IPFGsm class. Upon submission of a form, the location data will be sent as a parameter with the selected name (gpsElement in this example).
<?php
      require "../lib/ipfaces-php-lib-1.1.php";


      $form = new IPFForm();

      $screen = $form->addScreen("How Far Is It?");

      $screen->addLabel("You can find distance between your position and selected city.");

      $select = new IPFSelect("countrySelect", "1", "Distance to", "list" );

      $select->addOption("35.17 149.13 Australia Canberra", "Canberra");
      $select->addOption("51.30 0.10 UK London", "London");
      $select->addOption("50.05 14.28 Czech Prague", "Prague");
      $select->addOption("38.53 77.02 USA Washington", "Washington");

      $select->Icon = "../img/distcalc.png";
      $screen->addItem($select);

      $screen->addButton("backButton", "1", "Examples", "../index.php", IPFButton::BUTTON_TYPE_LINK, IPFButton::BUTTON_POSITION_BACK);

      $screen->addButton("submitButton", "0", "Calculate" , "distance.php", IPFButton::BUTTON_TYPE_SUBMIT, IPFButton::BUTTON_POSITION_FORWARD);

      $screen->addGps("gpsElement");

      $form->render();
?>
 

No comments:

Post a Comment