adjust-icon

Unity SDK 集成

如果您想使用 Unity SDK 监测广告收入,可以借助 SDK 到 SDK 集成,将数据发送到 Adjust 服务器。

操作前须知

要使用该功能,请先为您的应用下载并设置对应的 Adjust iOS SDK。

要了解更多信息,请查看 Unity Mediation API展示事件文档。

示例

@interface ViewController()
@property(nonatomic, strong) UMSImpressionListenerWithBlocks * listener;
@end
@implementation ViewController
- (void) viewDidLoad {
[super viewDidLoad];
self.listener = [[UMSImpressionListenerWithBlocks alloc] init];
self.listener.onImpressionBlock = ^ (NSString *adUnitId, UMSImpressionData *impressionData) {
if (impressionData) {
NSLog(@ "impressionData: %@", [impressionData getJsonRepresentation]);
// send impression data to Adjust
ADJAdRevenue *adRevenue = [[ADJAdRevenue alloc]
initWithSource:@"unity_sdk"];
adjustAdRevenue.setRevenue([impressionData.revenue doubleValue], impressionData.currency);
// optional fields
adjustAdRevenue.setAdRevenueNetwork(impressionData.adSourceName);
adjustAdRevenue.setAdRevenueUnit(impressionData.adUnitId);
adjustAdRevenue.setAdRevenuePlacement(impressionData.adSourceInstance);
// Send Adjust ad revenue
Adjust.trackAdRevenue(adjustAdRevenue);
} else {
NSLog(@ "Data does not exist due to not enabling User-Level Reporting");
}
};
[UMSImpressionEventPublisher subscribe: self.listener];
}
@end