playMaker

Author Topic: Admob actions not show ads  (Read 733 times)

Seiryu33

  • Full Member
  • ***
  • Posts: 133
Admob actions not show ads
« on: August 27, 2020, 04:49:19 AM »
Okay I've tried for three days to write a custom action to use with Playmaker that specifically works with Admob. I've already signed up and set up all the my ads, though Google states clearly not to use real ads for testing, so I've used the dummy adUnitIds provided by Google and installed the Mobileads plugin. To preface, I'm not a programmer, so I have no ideas why it won't work. For example, I've been trying to write an action for banner ads. Here's the most recent:

Code: [Select]
using UnityEngine;
using System;
using GoogleMobileAds;
using GoogleMobileAds.Api;
using GoogleMobileAds.Common;

namespace HutongGames.Playmaker.Actions

[ActionCategory("Admob")]

public class ShowBanner : FsmStateAction

{
private BannerView bannerView;
public static ShowBanner current;

void Start()
{

current = this;

RequestBanner();

this.bannerView.Show();

public void RequestBanner()

{

#if UNITY_EDITOR

string adUnitId = "unused";

#elif UNITY_ANDROID

string adUnitId = "ca-app-pub-xxxxxxxxxxx/xxxxxxxxx";

#elif UNITY_IPHONE

string adUnitId = "ca-app-pub-xxxxxxxxxxx/xxxxxxxxx";

#else
string adUnitId = "unexpected_platform";

bannerView = new BannerView(adUnitId, Adsize.SmartBanner, Adposition.Bottom);

bannerView.OnAdLoaded += HandleOnAdLoaded;
bannerView. OnAdFailedToLoad += HandleAdFailedToLoad;
bannerView. OnAdOpening += HandleOnAdOpening;
bannerView. OnAdClosed += HandleOnAdClosed;
bannerView. OnAdLeavingApplication += HandleOnAdLeavingApplication

bannerView. LoadAd(createAdRequest));


}

private Adrequest createAdRequest()
{

return new Adrequest.Builder()
.AddTestDevice(Adrequest.TestDeviceSimulator)
.AddTestDevice("123456789ABCDEF")
.AddKeyword("game")
.SetGender(Gender. " " )
.SetBirthday(1981, 7, 8
.TagForChildDirectiveTreatmenyt(false)
.AddExtra("color_bg, 9B30FF")
.Build();

}

#region Banner callbacks hander's

public void HandleOnAdLoaded(object senders, EventArgs args)

{
 
Monobehaviour. print("HandleOnAdLoaded");

}

public void HandleAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)

{

Monobehaviour.print("HandleFailedToReceiveAd event received with message:  " + args);

public void HandleOnAdOpening(object senders, EventArgs args)

{
 
Monobehaviour. print("HandleOnAdOpening");

}

public void HandleOnAdClosing(object senders, EventArgs args)

{
 
Monobehaviour. print("HandleOnAdClosing");


}
public void HandleOnLeavingApplication(object senders, EventArgs args)

{
 
Monobehaviour. print("HandleOnLeavingApplication
");

}

#endregion

}

}
I was trying to write actions for Interstitial and RewardAds but same outcome. I must've watched eight tutorials for this problem, but I'm stuck. The ads aren't showing up in the Editor or the Build, which means unlikely to play ads even with a published build. Any advice?
« Last Edit: August 27, 2020, 05:59:29 AM by djaydino »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Admob actions not show ads
« Reply #1 on: August 27, 2020, 06:12:23 AM »
Hi.
I wrapped you code (you can use the # button to do that :) )

Actually before you could only test ads in builds (on mobile only)
I do not know if that has changed as its been a long time ago that i did something for mobile.

But your code will not work as an action.

Have a look to other actions so you can understand better how they work.

This video can help as well :