Friday, August 24, 2012

Hit The Market & Get Audience : Planning Metro style Apps Effectively


Basically i am working as a  mobile application developer for a Bridge-India for developing mobile applications.  After finishing some application, i just tried some market studies to enhance the mobile app development. I just found that there are lots of applications which is not cross the small download limit of 100. There are thousands of applications which are not crossing the limit. So i just asked myself why these apps not hitting the market even if it is free? I found that there are lots of problems in UI design , User experience, Concept and lot more. These are the major reasons why the users are not using these apps.What i am going to tell is “Planing is the most important phase when you design a app”.
So lets get started :- Key Things To Remember When You Develop Mobile Apps [In Planning Phase]
This is the most important part, think very well what your app is great at. For these question we need to ask many questions to our self. What’s your app about? Speciality of Our app? and lot more… If you find good answers for these question, we will move to the next step.
If you follow these steps, you will definitely successes in the market place
1. Decide what your app is great at
2. Decide what user activities to support
3. Decide what kind out Users are to be used 
4. Decide what features to include 
5. Decide how to monetize your app
6. Design the UI for your app
7. Make a good first impression
8. Prototype and validate your design
9. Review the entire process once again
thats it you are Done…

Building An iOS App With Sencha Touch 2 And Phonegap (Cordova)


In this tutorial i am going to explain about Packaging Sencha Touch 2 with PhoneGap ( Cordova). By the help of phonegap / Cordova any HTML developers can develop iPhone / Android /  Bada / BadaWac / Blackberry / symbian / webos /windows native applications.
About Phone Gap
It will help you to take the advantage of HTML5 and css3, Javascript to manage the code, Access the native features of mobile device etc. you can learn more about phonegap from here 
About Sencha Touch 2
Sencha Touch 2, a high-performance HTML5 mobile application framework, is the cornerstone of the Sencha HTML5 platform. You can learn more about Sencha Touch 2 from here 
System Requirements & Downloads 
To follow this tutorial you have to download the following thing to your mac machine.
1. Sencha Touch  2. Sencha SDK Tools  3. Phonegap / Cordova
here is the downloading link.
lets get start…
extract the sencha touch 2.0.1 to your webserver, install the sencha Touch sdk tool, after that install the phonegap / Cordova template  to the Xcode.
Step 1:- Creating Sencha Touch 2.0 app
In the first step,  navigate into the Sencha Touch SDK directory usingTerminal.app, Next we need to create a web app named phonegap,
for that we can use following code snippet in the terminal.
sencha app create PhoneGap ~/path-to-your-new-app all
Step 2:- get in to the app Directory using the following code snippet
cd PhoneGap/
 sencha package build -e native
After that delete the content’s inside the build folder .
Your application can now be viewed in a browser:
now We need to now link that JavaScript file up into our Sencha Touch application. Traditionally you would do this by including it in the index.html file, but that is no longer the case. Simply open up app.json and add it to the top of the js array of files:
"js": [
    {
        "path": "cordova-1.7.0.js"
    },
    {
        "path": "sdk/sencha-touch-all.js"
    },
    {
        "path": "app.js",
        "bundle": true,
        "update": "delta"
    }
]
Now you finished with your web app. Next we need to create a IOS web wrapper, for that we need to use the Phonegap.
Creating the Xcode Project
Open up Xcode and create a new project (File > New > Project). You will be presented with the following dialog:

Ensure Cordova-based Application is selected under the iOS > Application section. Press next.Give your application a name as phonegap and a company identifier and press next.
Next you must select where you want to save your Xcode Project. Put this inside the build folder of your new Sencha Touch Application

Next step, we need to build the iphone project. After that we need to drag a generated www folder onto the Project in Xcode. Do this by right clicking on the project name in Xcode and selecting Show in Finder:

You will now see the www folder which you need to drag onto the project:

On the next dialog it is important to select Create folder references for any added folders:

Now go back to the www folder and delete everything inside it. Our Sencha Touch Application will be going there. At this point it is a good idea to rename the Xcode Project folder inside the build folder to phonegap – just to make it a little cleaner.
Configure your sencha application where to build
The final step is to open app.json and change the buildPath (right at the bottom of the file) of the package version of your app. We want it to point to the www folder:
"buildPaths": {
    "testing": "build/testing",
    "production": "build/production",
    "package": "build/phonegap/www",
    "native": "build/native"
}
Now you can run the following command in the terminal
sencha app build package
You are done. now just run the xocde project. you are successfully packed the senha touch project to the phone gap.























Working with JSON in iOS 5


In iOS 5 apple introduced a new built –in API for communicating with the JSON.This API is really helpful to work with JSON read and write functionalities. If you are not familiar with JSON (JavaScript Object Notation), it is a lightweight data-interchange format that is often used to send data over a network connection. It is easy for humans to read and write. It is easy for machines to parse and generate.
For example, If you have a array of Data (in String Format), the JSON representation would be:
[ "firstName", "lastName", "age", "place", "email"]
JSON objects are also come along with the pet objects with member variables (key value pair) format, the JSON representation would be:
[
{ "firstName": "John", "lastName": "Smith", "age": "27","place": "America", "email": "john_smith@gmail.com" }
]
It’s So simple and You can learn more about the JSON from here.
Why JSON is Important?
Nowadays, most of the powerful third party’s such as Google, Yahoo provides JSON API to interchange data with the server and client. When you make a web service call with a query string, it will return JSON formatted data. When you write your own web services, it is easy to convert your data into JSON format, and also the learning part of JSON is quite simple. Most attractive part of JSON based web service is Intrinsic Simplicity.
In this tutorial, we will learn about how we can work with JSON in IOS 5.0 and above.
Working with JSON in IOS 5 and above:-
In the previous versions of IOS (below version 5), to parse the JSON data we are using a third party library know usSBJson. It is a bit heavy process and we need to include all the files to our project, and also the data manipulation process is also bit hard.
So finally apple added a JSON Parser in to the Cocoa library. From my personal experience, I played many times with JSON in many projects, so I feel very comfortable like the way the apple did in iOS 5.With the help of this library we can easily turn objects like NSString, NSNumber, NSArray and NSDictionary into JSON data and vice versa, no need to include external libraries – everything is done natively and super fast.
Overview:-
  • Top level object must be NSArray or  NSDictionary .
  • All objects are instances of NSString, NSNumber, NSArray, NSDictionary, or NSNull.
  • All dictionary keys are instances of NSString.
  • All Numbers are not NaN or infinity.
Class Methods:-
+ (NSData *)dataWithJSONObject:(id)obj options:(NSJSONWritingOptions)opt error:(NSError **)error
 
+ (BOOL)isValidJSONObject:(id)obj
 
+ (id)JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)opt error:(NSError **)error
 
+(id)JSONObjectWithStream:(NSInputStream*)stream options:(NSJSONReadingOptions)opt error:(NSError **)error
 
+(NSInteger)writeJSONObject:(id)obj toStream:(NSOutputStream*)stream options:(NSJSONWritingOptions)opt error:(NSError **)error
In this tutorial, we are going to get hands-on experience in the new native JSON support. Step by step we are going to build a sample application which helps us to understand the working of JSON native Support.
Getting Started:-
Open Xcode from the developer tools, Click on the Create new project and select the single view based application. Enter the Product name as JSON,enter the Company identifier name and change the device family to iPhone,click Next and save the project by clicking Create.Start up screen will look like below.
josn ios 5
Next we need to add a text file to the project,for that we need to right click on the project click on the other category and click on the empty file template. Now we need to rename the empty file as jsonText.txt . Next we need to add the JSON data to the jsonText.txt. The JSON data representation will be look like this:
{"AppBgColor": "eeeeee","AppName": "JSON Demo","AppVersion": "1.0","developerName": "safil", "contact": "safilsunny@gmail.com"}
Now we need to add some UI elements to the ViewController.xib and add corresponding IBOutlet in the ViewController.h file, and wire the IBOutlet to the xib
@interface ViewController : UIViewController
{
    IBOutlet UILabel *AppBgColorLabel;
    IBOutlet UILabel *AppNameLabel;
    IBOutlet UILabel *AppVersionLabel;
    IBOutlet UILabel *developerNameLabel;
    IBOutlet UILabel *contactLabel;
}
json parser ios 5 tutorial
Now we need to create a method to read the local jsonText.txt data and parse the JSON to the Foundation objects. Open the ViewController.m and create a function to interact with the parse JSON text button in the UI. The below code snippet will indicate the implementation of JSON Parser .
//interacting with the parse JSON Button with the UI
-(IBAction)parseLocalJSON:(id)sender{
    //Getting the file path from the local bundle.
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"jsonText" ofType:@"txt"];
    //Convert the content of file to NSData
    NSData* data = [NSData dataWithContentsOfFile:filePath];
    //fetch the data to the JSON Foundation opject.
    [self performSelectorOnMainThread:@selector(fetchedData:)
                           withObject:data waitUntilDone:YES];
}
the above function will interact with the UI button named parse JSON Text, when ou touch up inside the button, it will call the parseLocalJSON function and convert the jsonText file data to the NSData. Next code snippet will explain about the conversion model of NSData to the NSDictionary.
- (void)fetchedData:(NSData *)responseData {
    //parse out the json data
    NSError* error;
    NSDictionary    *json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
    //process the JSON Foundation object to the view.
    [self processData:json];
}
At the end of the fetchedData function it will call the processData function with the JSON object dictionary as parameter. This function will separate according to the key-value process.
-(void)processData:(NSDictionary *) JSONObject{
   NSString        *AppBgColor = [JSONObject valueForKey:@"AppBgColor"];
    NSString        *AppName    = [JSONObject valueForKey:@"AppName"];
    NSString        *AppVersion = [JSONObject valueForKey:@"AppVersion"];
    NSString        *developerName =[JSONObject valueForKey:@"developerName"];
    NSString        *contact =[JSONObject valueForKey:@"contact"];
    NSLog(@"AppBgColor: %@", AppBgColor);
    NSLog(@"AppName: %@", AppName);
    NSLog(@"AppVersion: %@",AppVersion);
    NSLog(@"developerName: %@",developerName);
    NSLog(@"contact: %@",contact);
    AppBgColorLabel.text =AppBgColor;
    AppNameLabel.text =AppName;
    AppVersionLabel.text = AppVersion;
    developerNameLabel.text=developerName;
    contactLabel.text=contact;
   self.view.backgroundColor =[UIColor greenColor];
}
OK! Let’s have a look – hit Run and see what comes up:
iphone 5 json tutorial























Now touch up inside the Parse JSON text button, it will change the UI according to the JSON Value.




instead of parsing the local JSON text file we can use the data from the live server,for that we need to specify the url path like this
    NSURL *url =[NSURL URLWithString:@"http://safilsunny.com/webservice"];
     NSData* data = [NSData dataWithContentsOfURL:url];
Just replace this code snippet with the above code.
//Getting the file path from the local bundle.
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"jsonText" ofType:@"txt"];
    //Convert the content of file to NSData
    NSData* data = [NSData dataWithContentsOfFile:filePath];
You are done. You can download the source code from here. happy coding…