cocos2dで作ったアプリにAppliPromotionを組み込んでみた
面白いサービスがあるので試してみました。
http://www.applipromotion.com/
自分のアプリ内で他のアプリを紹介した分、同じ仕組みを導入している他のアプリで、
自分のアプリが紹介される仕組みのようです。
SDKの導入方法は公式サイトに手順が載っていますが、cocos2dアプリに導入してみたので
メモとして残しておきます。
動作確認したバージョン
・cocos2d 1.0.1
・Xcode 4.5.1
公式サイトではViewControllerクラスにいくつかの処理を記述するように記載されていますが、
cocos2dアプリではAppDelegateに記述したほうがいいのではないかと個人的には思っています。
AppDelegate.h
@interface AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
RootViewController *viewController;
UIViewController *appliPromotionView;
}
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic,retain)RootViewController *viewController;
-(void)showAppliPromotion;
@end
AppDelegate.m
... -(void) applicationDidEnterBackground:(UIApplication*)application { // AppliPromotionWallがあるなら非表示に if(appliPromotionView != NULL) { [viewController dismissModalViewControllerAnimated:NO]; [appliPromotionView release]; appliPromotionView = NULL; } [[CCDirector sharedDirector] stopAnimation]; } ... - (void)dealloc { // AppliPromotionViewを解放 if(appliPromotionView != NULL) { [appliPromotionView release]; appliPromotionView = NULL; } [[CCDirector sharedDirector] end]; [window release]; [super dealloc]; } // AppliPromotionWallを表示する -(void)showAppliPromotion { if(appliPromotionView != NULL) { [appliPromotionView release]; } appliPromotionView = [AppliPromotionSDK showAppliPromotionWall:viewController orientation:UIInterfaceOrientationPortrait]; [appliPromotionView retain]; }
Wallを開く処理を実装します。
アプリを閉じた場合などにWallを閉じる部分もAppDelegate内で実装しています。
AppliPromotionのWall呼び出し
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [delegate showAppliPromotion];
AppDelegateを取得してWallを開く処理を実行します。
AppliPromotionは面白い仕組みだと思うので、アプリ作るときは積極的にいれていこうかなと思います。