2014-02-12 51 views
0

我正在使用RevMob中的广告开发我正在开发的应用程序,我想知道的是如何在每次应用程序开放时显示全屏广告。我无法弄清楚如何做到这一点,并且我在网络上没有发现任何关于此的信息。感谢您的帮助!显示全屏广告每5个应用程序开放

我使用当前的代码是在AppDelegate.m:

- (void)applicationDidBecomeActive:(UIApplication *)application 
{ 
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 

[RevMobAds session].parallaxMode = RevMobParallaxModeOff; 
     [[RevMobAds session] showFullscreen]; 
} 
+4

请不要这样做。想想你的用户。我最近清除了一个更有用的应用程序,因为他们开始这样做。 – rmaddy

+0

而不是每隔5次发起一次或许每天一次左右? – CokePokes

+1

同意@rmaddy。广告是可以的,但它们应该在一些侵扰性最小的时间显示,而不是在应用程序启动时显示。每个文档都会保存,等级被击败后等等。 –

回答

2

NSUserDefaults的使用存储的应用程序已经打开的时间量,并在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

每次递增它,然后做什么你想要做的,只要它被打开5次:]

例:

NSInteger timesLaunched = [[NSUserDefaults standardUserDefaults] integerForKey:@"timeslaunched"] 
timesLaunched++ 
[[NSUserDefaults standardUserDefaults] setInteger:timesLaunched forKey:@"timeslaunched]; 

if (timesLaunched % 5 == 0) { 
    // Show Ads 
} 
+1

我建议只使用'integerForKey:'和'setInteger:forKey:'。没有NSNumber转换,你的代码将会更干净。 –

+0

@AaronBrager好评,不知道为什么我滑下心头:] – Jack

相关问题