Archive for

April, 2011

...

Implementing iAd in iPhone applications

no comments

There are a couple of tricks to implementing iAd in iPhone applications that are not 100% spelled out in the documentation provided by Apple. If you do not implement right your app will crash on phones running older versions of iOS such as iOS4.1 and iOS3.

For your .h file:

#import <UIKit/UIKit.h>;
#import <iAd/iAd.h>;
@interface iAdViewController : UIViewController <ADBannerViewDelegate> {
	ADBannerView *adView;
 	BOOL bannerIsVisible;
}
@property (nonatomic,assign) BOOL bannerIsVisible;
@end

In the .m file you need the following:

- (void) viewWillAppear:(BOOL)animated {
	// check if iAd is available
	Class classAdBannerView = NSClassFromString(@"ADBannerView");
	if (classAdBannerView) {
		// create iAd
		ADBannerView *bannerView = [[classAdBannerView alloc] initWithFrame:CGRectZero];

		if (&ADBannerContentSizeIdentifierPortrait != nil) {
			// NEWER
			DLog(@"NEWER");
			bannerView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
			bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
		} else {
			// OLDER
			DLog(@"OLDER");
			bannerView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
			bannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
		}

		bannerView.delegate=self;

		self.adView = bannerView;
		[self.view addSubview:adView];
		self.bannerIsVisible=NO;
		[bannerView release];

	}
	[super viewWillAppear: animated];
}

I am creating the bannerView programatically in order to have the app also work on pre iOS 4.1 devices. The check for ADBannerContentSizeIdentifierPortrait is to see if the user is using iOS 4.1 or newer iOS. In iOS 4.1 the identifiers were based on size – but in newer iOS the iPad got iAds and the size no longer made sense – thus the landscape/portrait designations.

Finally – if your app supports multiple interface orientations – you need to let the banner know that the device rotated so it can show the right size ad.

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

    if (&ADBannerContentSizeIdentifierPortrait != nil) {
        // NEWER
		DLog(@"NEWER");
        if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation))
            adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
        else
            adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
    } else {
        // OLDER
		DLog(@"OLDER");
        if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation))
            adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier480x32;
        else
            adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
    }
}
Share

Facebook crack down on “spammy” apps

16 comments

Today I got an email from Facebook saying that (without warning) they have shut down the LogYourRun Facebook app.  The reason for this is that a Facebook algorithm had determined that the application was “spammy”.  This is a huge surprise to me and the thousands of users that use this app on a daily basis to brag about their exercise activities.  The application makes use of very basic Facebook stream post functionality provided by their iPhone SDK.  The post dialog, per Facebook’s terms, is not pre-filled with any information in the message field and requires the user to 1) actively enter their message and 2) press the post button.  There is nothing automated about the posting and it does not happen in the background – the user is fully aware that they are posting the activity.  The screenshot below shows an example of one of these spammy post:

The removal of this app is a huge let down since the the LogYourRun iPhone application relies on the application ID of the Facebook app in order to let people post their activity information on Facebook.  In addition to taking down the app they also took down the app’s Facebook page – so I have now lost all mode of communication with the application users and my inbox is currently getting flooded by emails from users letting me know that the app is no-longer working.

I am used to developing apps on a closed system – the iPhone – so I am used to following directions on how the user experience should be and what I can and cannot do.  For Facebook applications the terms of service is described in their Platform Policies (http://developers.facebook.com/policy).  The terms in this policy are very nebulous and include things such as “Create a great user experience” and “Be trustworthy” but does not actually define what “spammy” is – though from my albeit infrequent use of Facebook, I would think that Farmville would fit that description better than the LogYourRun application.  In addition I do not see a single term in the document that the LogYourRun app violates.  The app clearly pops up a stream.publish dialog (created using the Facebook JS library on the web or their SDK on the iPhone!) which the user can clearly decide to click post or skip.

I tried appealing the removal of the app and I must say that I appreciate that they got back to me within a couple of hours – though the reply could have easily come from the same algorithm that deleted the app (see below).  It crushed all hopes of ever reviving the app and restoring communication to the over 30K users of the app.

So now I am left with having to update the iPhone app so it does not link to the broken Facebook app.  It was surprisingly easy to setup a new application – which is probably why they need to have algorithms for taking them down also.  This will allow me to go back to being an enabler of my evil spamming users so they can once again brag about their exercise activities.

Share