Why my Admob is not working? - unity3d

I just published a game I made using Unity3D to Google Play. When I made tests before putting the game on the strore - I was able to see test ads. Now, that my game is on the store - I can't see any banner ads.
This is my code for showing adds, what's wrong here?
BannerView BV;
string adUnitId = "ca-app-pub-123456789/987654321";
void Start()
{
BV = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top);
RB(); //Request Banner
SB(); //Show Banner
}
private AdRequest createAdRequest()
{
return new AdRequest.Builder()
.AddKeyword("Game")
.SetGender(Gender.Male)
.SetBirthday(new DateTime(1988, 9, 4))
.TagForChildDirectedTreatment(true)
.Build();
}
void RB()
{
BV.LoadAd(createAdRequest());
}
internal void SB()
{
BV.Show();
}

Look at your log. It will tell you if an ad request has been made and what the result was.
If there are no ads to display, it will test you.
I suspect that is what is happening.

Related

GvrEventSystem vs EventSystem

Working on a Unity hybrid VR (cardboard) /2D app. The cardboard side of it works fine. I am having trouble with the 2D/VR switching.
When I am in 2D mode, reticle does not move, although screen taps register. So the app seems unaware of the gyro.
I feel like I am missing something fundamental here. I have a GvrEventSystem prefab that has both an EventSystem and GvrPointerInputModule components.
What obvious thing am I over-looking?
ETA:
I have been asked to add relevant code. Here is the code for 2D-VR switching on-the-fly. This code executes w/out error, and the app switches between VR and 2D mode every 3 seconds:
readonly string NONE_STRING = "";
readonly string CARDBOARD_STRING = "cardboard";
void Start()
{
Invoke("GoPhone", 3.0f);
}
void GoPhone()
{
SetVREnabled(false);
Invoke("GoVR", 3.0f);
}
void GoVR()
{
SetVREnabled(true);
Invoke("GoPhone", 3.0f);
}
void SetVREnabled(bool isEnabled)
{
if (isEnabled)
{
StartCoroutine(LoadDevice(CARDBOARD_STRING));
}
else
{
StartCoroutine(LoadDevice(NONE_STRING));
}
}
IEnumerator LoadDevice(string newDevice)
{
if (String.Compare(XRSettings.loadedDeviceName, newDevice, true) != 0)
{
XRSettings.LoadDeviceByName(newDevice);
yield return null;
if (!XRSettings.loadedDeviceName.Equals(NONE_STRING))
XRSettings.enabled = true;
}
}
Although I feel like my problem is a configuration problem, and not a code problem. In the editor, which does not support VR mode, the app behaves in 2D mode as expected.
Also ETA:
JIC
User error! I did not follow the "Magic Window" instructions as detailed at https://developers.google.com/vr/develop/unity/guides/magic-window... let my folly be a warning to future generations!

Oculus Quest Issue with UnityWebRequest

I am trying to make a unityWebRequest to an API and everything runs smoothly on a normal unity app, but when I transfer the application to my oculus quest as soon as the method "checkCode()" is called triggering the GetAuthRequest() method that does the unityWebRequest the oculus application crashes.
I've tried rewriting the code in a couple of different ways and nothing seems to be fixing the issue. My Quest has internet access and I believe I have Android SDK installed.
public void CheckCode()
{
StartCoroutine(GetAuthRequest("http://myURL/", attemptedCode));
}
IEnumerator GetAuthRequest(string uri, string attemptedCode)
{
setValue("IN_REQ");
using (UnityWebRequest webRequest = UnityWebRequest.Get(uri + attemptedCode))
{
//// Request and wait for the desired page.
yield return webRequest.SendWebRequest();
if (webRequest.isNetworkError)
{
setValue("NET_ERROR");
}
else
{
if (webRequest.downloadHandler.text.Equals("true"))
{
ClearCode();
setValue("Authenticated!");
}
else
{
ClearCode();
setValue("Error...");
}
}
}
}
try using "https://myURL/" instead of "http://myURL/"

using admob banners in unity

I'm using the following code to implement a banner ad at the bottom on my game screen in unity.
using GoogleMobileAds.Api;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AdScript : MonoBehaviour {
// Use this for initialization
void Start () {
showBannerAd();
}
private void showBannerAd()
{
string adID = "ca-app-pub-***********";
//***For Testing in the Device***
AdRequest request = new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator) // Simulator.
.AddTestDevice("***********") // My test device.
.Build();
//***For Production When Submit App***
//AdRequest request = new AdRequest.Builder().Build();
BannerView bannerAd = new BannerView(adID, AdSize.SmartBanner, AdPosition.Bottom);
bannerAd.LoadAd(request);
}
// Update is called once per frame
void Update () {
}
}
When I run it I get a notification on the log of:
Dummy .ctor
Dummy Createbannerview
Dummy LoadAd
but not a mock pop up banner saying "a banner ad will be implemented here"
Will the ads be implemented when published or did I misunderstand a step in the tutorial?
Admob banners will only be displayed when building to ios or Android and running it on a target device. You will never see a banner in the unity editor.
It does not matter if you run test ads or not, they just won't show in the editor.

Unity3d freeze after show Interstitial on iOs8

After show and close an Interstitial banner on ios8, the app freeze.
The app back to full operate after pressing Home button and re-activate it.
I'm working with unity 4.5.4f1, xcode6. This is the pseudo code that we're using:
...
ADInterstitialAd.onInterstitialWasLoaded += OnFullscreenLoaded;
...
private ADInterstitialAd fullscreenAd=null;
fullscreenAd = new ADInterstitialAd(true);
...
void OnFullscreenLoaded()
{
if(!fullscreenAd.loaded) return;
fullscreenAd.Show();
}
Issue of unity fixed on 4.5.6
http://issuetracker.unity3d.com/issues/the-app-freezes-after-closing-an-adinterstitialad

How to integrate admob interstitial in Unity?

I am looking to integrate admob interstitial in Unity, i did it for banner but unable to find final solution for interstitial, any help would be appreciated.
I tied following links but it didn't work for Interstitial
https://github.com/googleads/googleads-mobile-plugins
Please do not suggest any paid plugin as Prime31 etc.
You can download the unity package from the google developer page here
If the free plugin doesn't suit your needs, you'll have to write your own native plugin or purchase on on the Asset Store. However, that plugin's README says it supports interstitials. Try following the instructions in the readme. If you already tried that and it didn't work, it would help if you tell us exactly what went wrong.
Taken from that readme:
Here is the minimal banner code to create an interstitial.
using GoogleMobileAds.Api;
...
// Initialize an InterstitialAd.
InterstitialAd interstitial = new InterstitialAd("MY_AD_UNIT_ID");
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
interstitial.LoadAd(request);
Unlike banners, interstitials need to be explicitly shown. At an appropriate stopping point in your app, check that the interstitail is ready before showing it:
if (interstitial.IsLoaded()) {
interstitial.Show();
}
There's a done Unity Package for AdMob which I used in my android game, you can find it in here: http://forum.unity3d.com/threads/admob-unity-package-that-work-with-unity-3-2-above.173292
Make sure to go through the whole thread because it needs a bit of tuning to get it working perfectly with newer unity versions.
Little help about the app publisher id - look for page7 on the thread.
try https://github.com/unity-plugins/Unity-Admob.
I have success with this one.
and code is much more easy.
using UnityEngine;
using System.Collections;
using admob;
public class admobdemo : MonoBehaviour {
// Use this for initialization
void Start () {
Admob.Instance().bannerEventHandler += onBannerEvent;
Admob.Instance().interstitialEventHandler += onInterstitialEvent;
}
// Update is called once per frame
void Update () {
}
void OnGUI(){
if (GUI.Button (new Rect (0, 0, 100, 60), "initadmob")) {
Admob ad = Admob.Instance();
#if UNITY_IOS
ad.initAdmob("ca-app-pub-27960454450664210/xxxxxxxxx", "ca-app-pub-279343530664210/xxxxxxxxxxx");
#else
ad.initAdmob("ca-app-pub-27960454450664210/xxxxxxxxx", "ca-app-pub-279343530664210/xxxxxxxxxxx");
#endif
// ad.setTesting(true);
}
if (GUI.Button(new Rect(120, 0, 100, 60), "showfull"))
{
Admob ad = Admob.Instance();
if (ad.isInterstitialReady())
{
ad.showInterstitial();
}
else
{
ad.loadInterstitial();
}
}
if (GUI.Button(new Rect(240, 100, 100, 60), "showbanner"))
{
Admob.Instance().showBannerRelative(AdSize.Banner, AdPosition.BOTTOM_CENTER, 0);
}
if (GUI.Button(new Rect(240, 200, 100, 60), "showbannerABS"))
{
Admob.Instance().showBannerAbsolute(AdSize.Banner, 0, 30);
}
if (GUI.Button(new Rect(240, 300, 100, 60), "hidebanner"))
{
Admob.Instance().removeBanner();
}
}
void onInterstitialEvent(string eventName, string msg)
{
Debug.Log("handler onAdmobEvent---" + eventName + " " + msg);
if (eventName == AdmobEvent.onAdLoaded)
{
Admob.Instance().showInterstitial();
}
}
void onBannerEvent(string eventName, string msg)
{
Debug.Log("handler onAdmobBannerEvent---" + eventName + " " + msg);
}
}
Here you go. Google's official Unity Plugin and they have code sample for Banner and Interstitial Ads.