socket.io Library for Titanium Mobile

Found a socket.io Library for Titanium Mobile.

https://github.com/nowelium/socket.io-titanium

socket.io Library is originally included in Node.JS, and someone brilliant migrated into Titanium Mobile.

And, currently there is no nowJS implementation for Titanium Mobile. But I investigated nowJS source code it used socket.io, and *maybe* it is possible to migrate into Titanium mobile as well. However, this is not impossible, because Kosso had made it, but just didn’t open source yet.

Real time apps using nowJS

Real time technology is powerful, syncing states between peers in finger tips.

A JavaScript framework built on Node.JS, which named nowJS, provides a very simple, reliable real time feature that easily sync states between client and server, written entirely in JavaScript.

It’s automatically sync the JavaScript variables and functions between clients and servers. Say call client’s functions from server, or call server’s function from client.

Links:

  1. nowJS Official Page http://nowjs.com
  2. nowJS Source code available on Github https://github.com/Flotype/now
  3. Flotype real time infrastructure http://flotype.com
  4. Real time messaging and synchronization using nowJS and Node.JS http://www.bennadel.com/blog/2171-Realtime-Messaging-And-Synchronization-With-NowJS-And-Node-js.htm
  5. nowJS Best Practices http://nowjs.com/bestpractices
  6. nowJS simplifying development of real time apps http://www.building43.com/videos/2011/08/02/nowjs-simplifying-development-of-real-time-apps/

Kranium a lightweight MVC framework for Titanium Mobile

Kranium is a lightweight MVC framework for JavaScript application. Its main aim is to simplify Titanium Mobile development.

Adam Renklint gave a post on getting started for Kranium.

Some advantages Kranium brought over than original Titanium mobile are as following.

  • Build interface elements grouped into tree structure using K as a root namespace, instead of using old ways, we add one label instance, one button instance, and then add one by one into windows. In old way, we cannot know exactly the orders the elements placed, until at the end we add one by one to the window, but using Kranium we can manage it well using the tree structure. (Refer here…)
  • Easily extends the elements instance. It provides an extendable class structure that is able to create our own UI interface element easily. For example, we want to create a label that showing our login status automatically when we log in and log out from our application. We can extend the original label type UI element, and register own custom events to inform the login status and update to the label UI element. (Refer here…)
  • Live updating UI modules. I haven’t tried but it sounded amazing and powerful. It said, built from Livetanium, you are able to see the changes of UI elements immediately on the simulator and the actual device whenever you made changes to the UI files or stylesheets. It is amazing, because currently I only can make change to the UI element to the JavaScript file and then click stop and start the simulator and see the changes and it takes some times, you know, when you design the UI layout, it’s frustrating. At the back end, it implemented Kranium watcher, that is able to monitor the file changes and pipe the changes through Node.JS server to the simulator or actual device in real time and you can see the real time updates of UI element on the simulator or actual device. It said it currently worked well in iOS only. (Refer here…)
  • Simple selector engine. Like jQuery, you can use the selector like $(".label .button").text("test") to modify the attributes of the UI elements. You can even chain the statements to include the other modification. Influenced from jQuery, Kranium also provides other utility methods such as .each(), .filter(), .find(), .parents() with the selector defined to modify the UI elements easily.

Kranium is very powerful as you can see, it made developments of Titanium Mobile easier and even quicker. But, I hoped that we can have a WYSIWYG editor in order to show the UI elements what exactly look liked inside the IDE without running it in the simulator or actual device.

Joli.js a lightweight ORM for Titanium Mobile

Researching Titanium Mobile development, I want to create a database application and I need a database framework or ORM (Object-Relational Mapper) to manage my entities without troubling with SQL.

Many available ORM frameworks written by JavaScript is capable of dealing with SQLite database that can worked with HTML5, Google Gears, and Titanium Mobile, and Joli.js is the one I found that is more suitable when used with Titanium Mobile.

Joli.js provides simplistic way to create database query, like amazing Query constructs (query().select(“tablename”).where(“name = ?”, “age”).execute()), and easier / extensible way to define the model entities. It is enough for simple application development. However, it does not support relationship association between entities (one-to-one, one-to-many) such like ActiveRecord did originally.

Fork out Joli.js demo on Github!

Extending Titanium Mobile with Native Module

Views this Slideshare as “Extending Titanium Mobile with Native Module”.

Or view on http://apps.facebook.com/imgshow/q:name=slideshare,code=8107992

This simply tells us how to extend Titanium Mobile JavaScript Application API with native module, say an iOS native module written in Objective-C. It guided us on how to build the bridge between Objective C and JavaScript.

Replicate Imgshow Sandbox into iPhone Apps

In my journey learning developing iPhone Apps, I try to replicate Imgshow Sandbox feature into iPhone Apps.

Imgshow Sandbox is a feature to test it out the services provided by Imgshow Platform. It is a web page integrated inside Help Content of Discuz Plugin of Imgshow Platform.

The original sample of Imgshow Sandbox can be found here:
Chinese Site: http://www.qxinnet.com/misc.php?mod=faq&action=plugin&id=qx_imgshow:help&topic=sandbox
English Site: http://www.discuz.my/misc.php?mod=faq&action=plugin&id=qx_imgshow:help&topic=sandbox

I am going to use Titanium API to make Imgshow Sandbox on iPhone Apps. The results would like this:

In the first screen, it shows a list of Imgshow Sandbox supported Services, with a thumbnail icon, name and description of the service.

Then, clicked on ‘youtube’ service, it brings us to a new window showing the parameters.

Enter a keyword, e.g. ‘Avril I love you’, a youtube song title, then click on ‘Show’ button. It will make an API request to Imgshow Platform and redirect you to the related Youtube video. In the back end, actually it sent an Imgshow Query to the Imgshow Platform server, in the form of (q:name=youtube,k=Avril I love you). You can however preview this Imgshow Query at this website, http://apps.facebook.com/imgshow/q:name=youtube,k=Avril I love you.

Here open the Youtube video in the iPhone embedded browser.

Back to the apps, we choose another service, such as ‘twitter’.

We enter a keyword, ‘Steve Job’, then click ‘Show’ button.

It will then open embedded browser to show the Twitter conversation box where back end it actually issued an API request to the Imgshow Platform. The example of this Imgshow query is in this form: (q:name=twitter,k=Steve Job)

This apps is just an experiment for imgshow API integration.

Played Titanium mobile framework

Just played and hello world to Titanium, another mobile apps framework like Phonegap, has the ability to develop iOS and Android apps using Javascript without learning native language Objective-C and Java.

Titanium has over 300 APIs, it bridged more and more native features than Phonegap. Titanium had bridged in native UI widgets and features into its own Titanium framework, while Phonegap only support HTML5 + CSS3 Web View Interface. In this case, Titanium provides API to build UI widget, such as Text Field, Table View, Button, using same and neutral Javascript API, the developers need not to bother the look-and-feel of widgets while Titanium take care of it. It is automatically rendered as iPhone-styled widgets while apps runs on iPhone or rendered as Android-styled widgets while apps runs on Android. Besides native hardware feature support such as Accelerometer, Compass, Camera, supported by both, Titanium has many other built-in API, such as it is able to initiate HTTP Client, or using TCP/IP Socket Stream, File System or Local Database Access and other useful utilities.

Titanium Javascript is compiled into application binaries and it can be run on the speed nearly to native apps. Again, Titanium Javascript is cross-platform over the non cross-platform Objective C and Java.

It has a standalone Eclipse-based IDE, which provides complete and useful hints when you code Titanium, and it is all free and open source. It has built in iPhone and Android simulator to test your apps. But when you need to debug on real iPhone, what I do is open the generated project setup in Xcode, and build there, and the whole process is damn smooth.

 

I’m lovin it.

 

Notes on Hello World Phonegap on Develop iPhone Apps

Notes on Hello World Phonegap on Develop iPhone Apps.

Phonegap is a mobile apps framework that can deliver cross-platform mobile apps (deployed on iPhone, iPad, Android, BlackBerry… ), utilizing web technologies (HTML5 + CSS3 + JS) we know, without knowing Objective-C (iPhone+iPad) or Java (Android). Phonegap actually runs your apps wrapped as an inner browser inside native apps. However, Phonegap provides JS-bridge to native phone features, such like Contacts, GPS, Accelerometer that you can simply call them using Javascript. The downside is that Phonegap framework has no built-in native look-and-feel widgets, but you can use Jquery Mobile framework along to create impressive mobile apps though.

Phonegap is also built-in supported by Adobe Dreamweaver CS 5.5, along with Jquery mobile supported, developers can easily develop and test iPhone native mobile apps right inside Dreamweaver. Apple had also announced to approve or accept apps developed by Phonegap to be available on Apps Store, that is a happy news to developers.

Before do Phonegap for iPhone, needs a Mac and had Xcode installed. And you need have access to Apple Developer Program, had Provisioning Profile configured. Then you can create a Phonegap project template from Xcode IDE. Along the process to get Phonegap runs on Xcode and an apps deployed to iPhone taken me half days to make it, here are some links or notes for future reference.

1. http://devclinic.com/devclinic/viewtopic.php?f=5&t=19
I found this post is very useful which give details and full steps to get signed certificates stuffs configured through Apple Developer Program and Xcode.

2. http://www.iphonedevsdk.com/forum/iphone-sdk-development/7209-putpkt-write-failed-broken-pipe.html
Sometimes, the error “putpkt write failed broken pipe” will randomly appeared.

3. http://iamcam.wordpress.com/2011/03/17/phonegap-xcode4/
Steps get phonegap runs on Xcode

Be careful on the first link to get everything ready before go to third link.

 

Besides Phonegap, Appcelerator Titanium is another option.