【问题标题】:Ads not working properly广告无法正常工作
【发布时间】:2014-12-10 11:30:32
【问题描述】:

以下是我的 Appdelegate.m 类中的代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[RevMobAds startSessionWithAppID:@"Id"];

// Override point for customization after application launch.
return YES;
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{ 

[[RevMobAds session] showBanner];

}

以下是我的 ViewController.h 类中的代码:

@interface ViewController : UIViewController<RevMobAdsDelegate>

@property ( nonatomic, strong)RevMobBanner *bannerWindow;

以下是我的 ViewController.m 类中的代码:

- (void)handleNotification:(NSNotification *)notification
{
if ([notification.name isEqualToString:@"showAd"])
{
    _bannerWindow = [[RevMobAds session] banner];
    [_bannerWindow showAd];
}
}

//RevMob required delegate method
 -(void) revmobAdDidFailWithError:(NSError *)error {
NSLog(@"[RevMob sample app] Ad failed: %@", error);
}

//revmob optional delegate method
-(void) revmobAdDidReceive {
NSLog(@"[RevMob sample app] ad loaded.");
} 

-(void) revmobAdDisplayed {
NSLog(@"[RevMob sample app] ad displayed.");
}

-(void) revmobUserClosedTheAd {
NSLog(@"[RevMob sample app] user clicked in the close button.");
}

-(void) revmobUserClickedInTheAd {
NSLog(@"[RevMob sample app] user clicked in the ad.");
} 

-(void) installDidReceive {
NSLog(@"[RevMob sample app] install did recieve.");
}

-(void) installDidFail{
NSLog(@"[RevMob sample app] install did fail.");
}

- (void)viewDidLoad
{
 [super viewDidLoad];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:@"showAd" object:nil];
}

以下是MyScene.m(我的主菜单)类中的代码:

-(id)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
    self.backgroundColor = [SKColor colorWithRed:(29.0f/255) green:(29.0f/255) blue:(29.0f/255) alpha:1.0];





    [[NSNotificationCenter defaultCenter] postNotificationName:@"showAd" object:nil];
    }
return self;
}

【问题讨论】:

  • 您是否已开始像 [RevMobAds startSessionWithAppID:@"APP_ID" andDelegate:self] 这样的会话; ?
  • 是的,我刚刚在我的实现文件中尝试过。仍然是相同的调试消息。您认为还有什么其他方法可以@saidozcan?

标签: objective-c sprite-kit ads revmob


【解决方案1】:

我在 StartApp 中使用此方法。试试这个。

//yourViewControl.m

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:@"showAd" object:nil];

- (void)handleNotification:(NSNotification *)notification
{
    if ([notification.name isEqualToString:@"showAd"]) 
    {
        [[RevMobAds session] showBanner];
    }
}

//yourSKScene

    [[NSNotificationCenter defaultCenter] postNotificationName:@"showAd" object:nil];//Call with this.

【讨论】:

  • 当我输入 [[NSNotificationCenter defaultCenter] addObserver:self 选择器:@selector(handleNotification:) name:@"showAd" object:nil];它说使用未声明的标识符“自我”。我把它放在我的 viewController.m 中是你把它放在哪里? @Valar Morghulis
  • 你应该放入 viewDidLoad
  • 嗯还是不行。当我运行它时,它显示“[RevMob] 正在启动 RevMobAds”,然后在运行大约 2 秒后显示“[RevMob] 警告:未启动 RevMob 会话”
  • 你能展示你的 appdelegate.m 并查看控制器代码吗?
  • 我编辑了顶部的代码并提供了与 RevMob 相关的所有代码。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多