Archive for the ‘iPhone Programing Tutorial’ Category

Create and handle button with flex mobile application

November 24th, 2011 No comments

Today we start with basic control of any development, a Button. Button is main control to take actions from user and respond to it.

First create new application as described in this post.

I choose Blank Template so I only get application file. Now add one view to src. I have added it to my package. Name it Buttons. To create new package, right click on src folder and then select New – >Package. Give name of package and click Finish.

Create New Package



Now create new view in this package with name Buttons. For that, right click on package we just created and then choose New -> MXML Component follow on screen instructions. This will create new view file for you.

Now replace content of application file with this:

<?xml version="1.0" encoding="utf-8"?>
<s:ViewNavigatorApplication xmlns:fx=""
			   xmlns:s="library://" applicationDPI="160" firstView="com.macymind.views.Buttons">
		<!-- Place non-visual elements (e.g., services, value objects) here -->

This will instruct that our fist start up view is Buttons.mxml

Now open Buttons.mxml from project explorer. Switch to design view and add one button from Components panel. If Components panel is not visible then display it from Window -> Show View -> Components

Rename text of button by double clicking on it. Now run your app. It should display button on view.

Now its time to handle tap event form that button. Select button in design view and from Properties panel, click on button beside of On Click label and choose Generate Event handler. This will crate black event handler function and add that button to click event of button.

Now place some trace in that event handler function, debug application and tap on button and see results in Console.

Do comment if you have any problem.

How to generate certificate and provisioning profile on apple developer site

May 21st, 2011 4 comments


Here are steps to generate certificate and provisioning profile from apple developer site for signing iphone application.

STEP 1: Open and login with your developer account. Note that you need to purchase $99 or $299 developer program from apple to do this. Once you login to developer site, you will get screen as shown in below image.

Apple Developer Provisioning Portal Home


STEP 2: Now from that screen click on iOS Provisioning Portal. This will open screen as shown in below image.

Apple Developer Provisioning Portal Home

STEP 3: Now click on Certificates from left navigation of previous page. Now on this page you can see two main tabs: Development and Distribution. So here you can create certificate for development and distribution separately. If you didn’t created certificate yet then you can see “Request Certificate” button. So click on that will open screen that will ask you for Certificate Signing Request(CSR) file. That you can create as from this post. You can see below screen once you click on Request Certificate” button. It will open screen as shown in below image.

STEP 4: Now choose CSR file as we have created in previous step as from this post and click on Submit button. I have created certificate from my team member account so I can’t see Distribution tab but you can see it from your mail developer account. Now this will create certificate for you. You need to approve this certificate from list of certificates available on your Developer or Distribution tab. Once you approved it, download and save it on your MAC.

STEP 5: Install certificate on Mac.

Once you have downloaded that certificate, just open that .cer file by double clicking on it. This will install your certificate to your development machine. Remember that you need to have private key for installing this certificate and you can get this private ket from Mac on which you have created your CSR. So remember to always backup your private key from your Mac. To get this private key, you need to open your keychain access program and find relevant private ket and take backup by right click on it and click on Export and follow on screen instructions.

STEP 6: Add App Id

Once you have completed with creating and installing certificate, you need to create application id for your unique iphone app. For this, click on App IDs from left navigation on apple iOS Provisioning Portal. Doing this will open screen as shown below.

Create Application IdSTEP 7: Now click on New App ID button. This will ask you for “Description” and unique “Bundle Identifier” as shown in below image.

New Application Identifier

STEP 8: Now provide Description to identify your app id. Write Bundle Identifier as reverse domain name format like com.macymind.myappname. Click on Submit will generate new app id for you.

STEP 9: Now its time to create provisioning profile. From left navigation of Provisioning Portal, Click on Provisioning link. This will show you list of all profiles for particular type as Development or Distribution. Click on New Profile on this screen and follow on screen instructions to create new provisioning profile. Now download this newly created Provisioning Profile on your mac. Now for installing this provisioning profile to your xCode, drag and drop this file on xCode icon on your dock.

Let me know if you have any problem or suggestion for this article.


How to Generate Certificate Signing Request (CSR)

May 20th, 2011 No comments

Here are steps to generate certificate signing request (CSR).

STEP 1: Open Keychain Access application on your MAC system.

STEP 2: Now from KeyChain Access menu choose Certificate Assistant > Request a Certificate From a Certificate Authority… as shown in below image.

Create Certificate Signing Request


STEP 3: STEP 2 will open form dialog as shown in below image. Provide “User Email Address” and “Common Name”. Select “Save to disk” option and click on Continue button.

NOTE: If you are using CSR for creating certificate on apple site then also select “Let me specify key pair information” and provide 2048 as key size when asked.

Create Certificate Signing Request

STEP 4: Once you complete STEP 3, it will ask you to specify destination and name of resulting CSR file. Give name and specify destination for CSR file. I used my desktop as destination and name as “CetificateSigningRequest.certSigningRequest” as shown in below image.


Create Certificate Signing Request


STEP 5: STEP 4 will save CSR on your specified destination. Below image show a confirmation message for successful saving of CSR file.

Create Certificate Signing RequestNow we have generated CSR file. You can use it for creating Certificate for Apple Developer Site and also for Push Notification.

Please feel free to write comment if you have any doubt.

Apple Push Notification Server is not working

May 13th, 2011 No comments


Today I noticed that, apple’s push notification server is not working.

I have tried to send push message but it was not able to connect to push notification gateway server.

Then I tried to ping on both production and development push gateway of apple, but it was failed.

Is there anybody facing same issue?
Anyone has solution for this?



This is issue with my hosting server. My Server was blocking out bound socket connection on port 2195 which is port used by apple push gateway server. So finally I have resolved this issue.

In built web browser for native iPhone app

May 6th, 2011 No comments

Hello Friends,

Today I am going to provide you with steps on how to create in built web browser for iPhone apps. Easy 6 step procedure.

Step 1: Create new project from xCode File->New Project. Choose “View-based Application” and give a name as “InAppBrowser”.

New Project


Step 2: Now xCode will create all minimum required files for you. Open “InAppBrowserViewController.xib” file from left panel and add one textfield to enter url. Add one button next to added text field and give it title as “Go”. So we will code on tap of this button to load url in browser. Now add UIWebView to this view as shown in below image.

Browser ViewStep 3: Now open “InAppBrowserViewController.h” and add below code to it.

@interface InAppBrowserViewController : UIViewController
IBOutlet UITextField *txtUrl;
IBOutlet UIWebView *webView;
- (IBAction)onGo:(id)sender;

Step 4: Now assign this newly created outlets to relevant textfield and webview and action to UIButton(Go) Touch Up Inside Event in Interface builder.

Step 5: Now add method implementation of onGo in “InAppBrowserViewController.m” file. Use below code for that.

- (IBAction)onGo:(id)sender
NSURL *url = [NSURL URLWithString:txtUrl.text];
[webView loadRequest:[NSURLRequest requestWithURL:url]];
[txtUrl resignFirstResponder];

Step 6: Now build and run your app. Enter in url textfield and tap on “Go” button. This will open Google in webview. See below screenshot for final output.

That’s it! We are done now. If you want to download code then click here.