Как включить рекламу с вознаграждением для привязки к Python на iOS?C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Как включить рекламу с вознаграждением для привязки к Python на iOS?

Сообщение Anonymous »

В настоящее время я пытаюсь создать мобильное приложение с рекламой с вознаграждением и борюсь с кодом в XCode.
На данный момент я уже интегрировал межстраничную рекламу и хотел бы адаптировать код для рекламы с вознаграждением.
Вот мой текущий рабочий код для межстраничной рекламы, адаптированный на основе чего-то, найденного на Github:

Код: Выделить всё

UIView *gView;
UIViewController *gViewColtroller;

@interface adInterstitial : NSObject
/// The interstitial ad.
@property(nonatomic, strong) GADInterstitial *interstitial;
@property (strong, nonatomic) GADRequest *request;
@end

@implementation adInterstitial

-(id)init {
[self createAndLoadInterstitial];
NSLog(@"adInterstitial init");
return self;
}

- (void)createAndLoadInterstitial {
self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"]; // test id
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = window.rootViewController;
self.interstitial.delegate = self;

GADRequest *request = [GADRequest request];
request.testDevices = @[ kGADSimulatorID, @"2077ef9a63d2b398840261c8221a0c9a" ];
[self.interstitial loadRequest:request];
NSLog(@"createAndLoadInterstitial");
}

- (void)interstitialWillDismissScreen:(GADInterstitial *)ad {
//  Method for reloading the object so that you can show ads again
NSLog(@"interstitialWillDismissScreen");
[self createAndLoadInterstitial];
}

- (void)InterstitialView {  // show interstitial ADS
if (self.interstitial.isReady) {
NSLog(@"Show interstitial ADS!");
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = window.rootViewController;
[self.interstitial presentFromRootViewController:rootViewController];
} else {
NSLog(@"interstitial Ad wasn't ready");
}
}
@end
А вот моя попытка с рекламой с вознаграждением:

Код: Выделить всё

@interface adRewarded : NSObject
/// The interstitial ad.
@property(nonatomic, strong) GADRewardedAd *rewarded;
@property (strong, nonatomic) GADRequest *request;
@end

@implementation adRewarded

-(id)init {
[self createAndLoadRewarded];
NSLog(@"adRewarded init");
return self;
}

- (void)createAndLoadRewarded {
self.rewarded = [[GADRewardedAd alloc] initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"]; // test id
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = window.rootViewController;
self.rewarded.delegate = self;

GADRequest *request = [GADRequest request];
request.testDevices = @[ kGADSimulatorID, @"2077ef9a63d2b398840261c8221a0c9a" ];
[self.rewarded loadRequest:request];
NSLog(@"createAndLoadRewarded");
}

- (void)interstitialWillDismissScreen:(GADRewardedAd *)ad {
//  Method for reloading the object so that you can show ads again
NSLog(@"rewardedWillDismissScreen");
[self createAndLoadRewarded];
}

- (void)RewardedView {  // show interstitial ADS
if (self.rewarded.isReady) {
NSLog(@"Show rewarded ADS!");
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = window.rootViewController;
[self.rewarded presentFromRootViewController:rootViewController];
} else {
NSLog(@"rewarded Ad wasn't ready");
}
}
@end
И я получаю ошибку в строке: self.rewarded.delegate = self;
Ошибка: свойство «делегат» не найдено в объекте типа 'GADRewardedAd'
Просто для информации, чтобы запустить рекламу на Python, я использую следующий код:

Код: Выделить всё

from pyobjus import autoclass
current_ad = autoclass("adInterstitial").alloc().init()
current_ad.show()
Я также пытался использовать документацию Google https://developers.google.com/admob/ios ... bjective-c, чтобы создать новую версию, но у меня возникли проблемы с объектом с именем ViewController.
Либо я получаю эту ошибку, если просто скопирую пример:

Код: Выделить всё

Cannot find interface declaration for ViewController;  did you mean UIViewController
или я получаю эту ошибку, если заменяю UIViewController:

Код: Выделить всё

Cannot synthesize weak property in file using manual reference counting
Не могли бы вы узнать, как это решить?
Заранее спасибо!

Подробнее здесь: https://stackoverflow.com/questions/785 ... hon-on-ios
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»