Share Your Source Code or Article

Do you have source code, articles, tutorials, web links, and books to share? You can write your own content here. You can even have your own blog.

Submit now...

Database Programming Made Easy

This tutorial will teach you step by step on how to connect and manipulate database. If you'd like to suggest a tutorial please write a comment at the bottom of this article.

Read more...

Hire Us to Do Your Work

Do you want a customized system? Do you want to setup your own website to do business? Then we are here to help you in your programming needs.

Read more...

Search

Creating iPhone application in PHP using iPFaces framework


0
Your rating: None
Language: 

iPFaces Mobile Application Framework

iPFaces is a flexible solution for easy development of form-oriented network mobile applications. With the iPFaces solution, mobile devices are able to render content received from a server using their native UI components. It uses thin presentation client (must be installed on device) to render application content. Using iPFaces it is possible to build an application where users can use their device's specific component behavior and additional device features, such as location service and additional graphic
components of the device (lists, pickers etc.).
iPFaces supports also Java and ASP.Net.

Architecture

The solution is based on the use of a thin presentation client installed on the device and an application/web server which generates the content for clients. The client and the server communicate with each other using the network.
The idea is similar to the web browser – web server model. The client sends HTTP(S) requests to the server and receives iPFaces specific HTTP(S) responses, where the content is an XML representation of the application's form which is be rendered on client-side together with the form's data.

iPFaces schema

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.

iPFaces
iPFaces
Form representation on the iPhone device and in a web browser

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.

  1. <?php
  2. require "path/to/ipfaces/library/ipfaces-php-lib-1.1.php";
  3. $ipf_form = new IPFForm();
  4. $ipf_screen = $ipf_form->addScreen("screen", "Hello World Application");
  5. $ipf_screen->addLabel("label", "Hello World!");
  6. $ipf_form->render();
  7. ?>

iPFaces
iPFaces
Hello World example

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).

  1. <?php
  2. require "../lib/ipfaces-php-lib-1.1.php";
  3. require "citydatabase.php";
  4. $form = new IPFForm();
  5. $screen = $form->addScreen("How Far Is It?");
  6. $screen->addLabel("You can find distance between your position and selected
  7. city.");
  8. $parser = new CityDatabase();
  9. if (isset($_COOKIE["city"])){
  10. $value = $_COOKIE["city"];
  11. }
  12. $select = new IPFSelect("citySelect", $value, "Distance to" ,"list" );
  13. $options = array();
  14. for($row = 0; $row < count($parser->data); $row++){
  15. $options[] = new IPFOption($row, $parser->data[$row]["City"]);
  16. }
  17. $select->Icon = "../img/distcalc.png";
  18. $select->addOptions($options);
  19. $screen->addItem($select);
  20. $screen->addGps("gpsElement");
  21. $screen->addButton("backButton", "1", "Examples", "../index.php",
  22. IPFButton::BUTTON_TYPE_LINK, IPFButton::BUTTON_POSITION_BACK);
  23. $screen->addButton("submitButton", "0", "Calculate" , "distance.php",
  24. IPFButton::BUTTON_TYPE_SUBMIT, IPFButton::BUTTON_POSITION_FORWARD);
  25. $form->render();
  26. ?>

iPFaces
Preview of application with location service

More examples can be found at www.ipfaces.org.




Post new comment

  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <java>, <java5>, <javascript>, <mysql>, <php>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • Links to specified hosts will have a rel="nofollow" added to them.

  • You may insert videos with [video:URL]

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.

Step by Step Java Tutorial

In this tutorial you will learn how to program with Java. It has a rich of information to be educated well with Java.

Read more...

Do You Have Question?

Do you have any question related to computer programming? Visit our forum and post new topic on the category you like. Be gentle when asking a question.

Ask now...

Point of Sale

Point of Sale is very useful especially for supermarkets or restaurants. I have included a barcode scanner in this program. Please check it out.

Read more...