0

我已根据 Chartboost 文档完成所有步骤,将 iOS SDK 集成到我的应用程序中。但在调用 Chartboost 的最后阶段出现编译错误:

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


    // Begin a user session. Must not be dependent on user actions or any prior network requests.
    // Must be called every time your app becomes active.
    [Chartboost startWithAppId:@"some_id" appSignature:@"some_signature" delegate:self];

    // Show an ad at location "CBLocationHomeScreen"
    [[Chartboost sharedChartboost] showInterstitial:CBLocationHomeScreen];

在调用startWithAppId方法时,我收到以下错误:

......../proj.ios_mac/ios/AppController.mm:101:126: Cannot initialize a parameter of type 'id<ChartboostDelegate>' with an lvalue of type 'AppController *'

4

2 回答 2

0

反而,

尝试使用此代码

Chartboost *cb = [Chartboost sharedChartboost];

cb.appId = @"some_id";
cb.appSignature = @"some_sig";

[cb startSession];

[cb showInterstitial];
于 2014-08-12T11:25:55.747 回答
0

对于可能遇到此线程的任何人,这是一个更新的答案。经测试可在 2015 年 2 月 16 日为 Chartboost版本 5.1.3工作

在您的 appController.mm 文件中添加以下导入:

#import <Chartboost/Chartboost.h>
#import <Chartboost/CBNewsfeed.h>
#import <CommonCrypto/CommonDigest.h>
#import <AdSupport/AdSupport.h>

接下来添加如下接口:

@interface AppController () <ChartboostDelegate>
@end

最后在你的 applicationDidBecomeActive 方法中添加:

- (void)applicationDidBecomeActive:(UIApplication *)application 
{
    [Chartboost startWithAppId:@"appID" appSignature:@"appSIG" delegate:self];
    [Chartboost showInterstitial:CBLocationHomeScreen];
    //[Chartboost showInterstitial:@"CBLocationHomeScreen"]; //older way
}
于 2015-02-16T10:48:39.243 回答