Archive

Archive for December, 2009

iPhone Note #19: Route-Me: Opensource mapping for the iphone

December 8th, 2009 rupert Comments off

Route-Me is an opensource mapping api similar to the MapKit.framework. The main project resides in googlecode (http://code.google.com/p/route-me/).

Part 1: Making the Sample Apps work.

1. Download the code from svn.
svn co http://route-me.googlecode.com/svn/trunk/ route-me

2. In the route-me directory, you would have 3 directories:
- MapView – this contains the mapping framework
- Proj4 – projection library.
- samples

3. Build MapView. I encountered some problems here, particularly this specific issue: Cannot build on 3.1 using iphone simulator.

How to make the build? Now, at the time of this writing, I have XCode3.1.4 and iPhone 3.0, 3.1, 3.1.2. Edit the project settings so that the “build” and “release” will point to use 3.0. If you encounter a problem, it is best to “Clean All”, remove the build directory, then “Build” again. To verfiy if you have a successful build, notice that libMapView.a was created.

routeme-libMapView.png

Note: Notice here that I have libMapView.a both in Debug-iphoneos/ and Debug-iphonesimulator/

No need to build Proj4 as long as it is sitting on the same directory where MapView is.

4. To test route-me, we can study from the samples directory. Let’s build samples/SampleMap. Notice that SampleMap has a reference to MapView.xcodeproj.

routeme-samplemap.png

Similarly, we can build this using 3.0 both in the simulator and device.

routeme-samplemap-ok.jpg

Part 2: Integrating with your own project.

Reference: http://code.google.com/p/route-me/wiki/EmbeddingGuide

1. Create a view-based project: MyRMSampleMap.

2. Project -> “Add To Project”. Make the reference type as “Relative to Project”.

routeme-referencing-mapview.jpg

3. Configure your project to have a direct dependency with MapView.xcodeproj. Follow the instructions exactly as stated from the EmbeddingGuide.

routeme-ref-dd.jpg

Click on the “Build” tab in your target’s info window.

Change the Configuration popup to read “All Configurations”, so that your changes can be made just once.

Find “Header Search Paths” under “Search Paths” (shortcut: type “header” in the search box at upper right of the target info window). Double-click on the ‘Header Search Paths’ text and add the path to the MapView directory contained in the route-me project located on your file system. (Note that if there are any spaces in the path, enclose the entire entry with “”. If the MapView project folder is placed next to your project’s project folder on the file system, you would have the following in the path: “../MapView”.

Check the ‘Recursive’ box and click Ok.

routeme-searchpaths.jpg

4. Make a test “Build”.

5. Add a reference to:
- QuartzCore.framework
- libsqlite3.dylib

6. Let’s add our mapview in the interface: MyRMSampleMapViewController.h

#import <UIKit/UIKit.h>
#import "RMMapView.h"
 
@interface MyRMSampleMapViewController : UIViewController {
	RMMapView *mapview;
}
 
@property(nonatomic, retain) RMMapView *mapview;
 
@end

7. In the implementation, add this snippet.

@synthesize mapview;
...
- (void)viewWillAppear:(BOOL)animated{
	mapview = [[RMMapView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 460.0f)];
	[mapview setBackgroundColor:[UIColor blackColor]];
 
	[self.view addSubview:mapview];
}

Download: MyRMSampleMap.zip

Categories: iphone Tags:

iPhone Note #18: Integrating Ads (AdMob) on your iPhone App

December 7th, 2009 rupert 2 comments

Basic Info

What is common with these ad platforms?
Each application is offered a unique id which needs to be specified during development.

What is publishing?
Publishing allows the developer to display (publish) ads on the native application.

What is CPM?
Impressions per thousand. Normally ad networks pays $1 for every 1000 CPM. So you need 1000 page views (not clicks) to earn a buck.

What is the fillrate?
The percentage of impressions served based on total requests for ads. This is number to look for when you get blank ads. How many of my clients gets an ad impression? I had 60%

What is the Click Through Rate (CTR)?
Out of 60% of my clients who had ad impressions, 6.18% of them clicked the ad. The more they get clicked, the higher your revenue.

Admob

Offers both publishing and analytics. Currently offers both iPhone and Android. Able to publish ads for native app and mobile websites. This is my preferred ad network of choice as it is easier to setup than the others. And just recently, it was swallowed by Google, whether that is good or bad for us, we have yet to know.

AdMob Iphone SDK Integration

1. After signing up/registering to Admob you need to add your application in “Sites & Apps” tab (2nd tab from the left).

2. Click on “Add Site/App” and you would be presented with what kind of site or app type (Mobile Web, Iphone App, Iphone Web and Android App). Select “Iphone App” and fill out the details..

3. If you go to “Sites & Apps”, there’s a link “Setup” just under the Quick Links. You could download a sample AdMob application there wherein your publisherId is already built-in. Here’s a sample (admob_iphone_sdk_20091119.tar.gz). Note that AdMob upgrade their code, notice the dates (20091119)? So it’s good practice to read the CHANGELOG.

4. Note your publisherId.

#pragma mark Admob delegate methods
- (NSString *)publisherId {
	return @"a14ac98028663b0"; // bayanihan
}

5. Make the sample application from AdMob run first before integrating your app.

// To receive test ads rather than real ads...
- (BOOL)useTestAd {
	return YES; //change this to NO later..
}

6. Normally, the problems/quirks I experience when integrating a 3rd Party Project are framework references. So, here’s mine:

admob_frameworks.png

Note: As of ver 20091119, I added MessageUI.framework, AudioToolbox.framework, MediaPlayer.framework. Prior to that build (200906xx), I don’t have those. If you are compiling against iPhoneOS version 3, then you would need to reference libAdMObDevice3_0.a and libAdMobSimulator3_0.a (to run it in the simulator–but you would take this reference off when making an actual build)

admob-iphoneos3.png

7. Now, that both the testAd (YES) is working, it might take you a few hours before the real ad comes in. Be patient. :)

8. Integrate to your project. AdMob provided detailed examples on how to integrate depending on your needs–Interface Builder (IB), Programmatically or TableView. Personally, I have used both IB and TableView and it works flawlessly.

9. I dont get an ad? I get an Ad? Which one? Check out the AdMobDelegate Methods.

- (void)didReceiveAd:(AdMobView *)adView {
	NSLog(@"AdMob: Did receive ad");
}
 
- (void)didFailToReceiveAd:(AdMobView *)adView {
	NSLog(@"AdMob: Did fail to receive ad");
 
	//[self createMobclix];
	//[bannerCell setNeedsLayout];
}

10. Now once you have AdMob going, you want to be more efficient and get higher fill rates. You can checkout other Ad Platforms (Mobclix, Adwhirl). Notice on step 9 above, that if I don’t get an ad from AdMob, I fire up an add from MobClix.

Categories: iphone Tags: