我已通过来自here
的Cocoapodspod 'ComScore'
整合了ComScore SDK
并将#import <ComScore/ComScore.h>
添加到我的Briding标题
在我的AppDelegate.swift
中 let publisherConfiguration = SCORPublisherConfiguration(builderBlock: {(_ builder: SCORPublisherConfigurationBuilder) -> Void in
builder.publisherId = "*******"
builder.publisherSecret = "*******"
builder.applicationName = "*******"
} as? (SCORPublisherConfigurationBuilder?) -> Void)
SCORAnalytics.configuration().addClient(with: publisherConfiguration)
SCORAnalytics.start()
但是没有将我的数据发送到服务器。
他们已经注意到以下作为其客观c示例应用程序中的实现(他们不直接支持Swift,我使用BridgingHeader集成)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
SCORPublisherConfiguration *publisherConfiguration = [SCORPublisherConfiguration publisherConfigurationWithBuilderBlock:^(SCORPublisherConfigurationBuilder *builder) {
builder.publisherId = @"1000001";
builder.publisherSecret = @"9c455c81a801d3832a2cd281843dff30";
}];
[[SCORAnalytics configuration] addClientWithConfiguration:publisherConfiguration];
[SCORAnalytics start];
return YES;
}
答案 0 :(得分:2)
正确的语法是
let check = SCORPublisherConfiguration(builderBlock: {(_ builder : SCORPublisherConfigurationBuilder!) -> Void in
builder.publisherId = "1000001"
builder.publisherSecret = "9c455c81a801d3832a2cd281843dff30"
builder.applicationName = "karthik_Test"
} )
SCORAnalytics.configuration().addClient(with: check)
SCORAnalytics.start()
和 ComScore框架需要 AdSupport框架不要忘记添加。