- Home /
Chartboost Ad not showing in Device
So i have been having trouble with this for 2 days straight and im wondering why my ads do not appear when i test on my android device. I followed everything from the Documentation, started a campaign after i added my app and also enable test mode. Here is 2 Seperate scripts one has everything from the documentation and the other shows the interstitial in my main menu script
Chartboost Script
using UnityEngine;
using System.Collections;
using Chartboost;
public class Chart : MonoBehaviour {
void OnEnable() {
// Initialize the Chartboost plugin
// Replace these with your own Android app ID and signature from the Chartboost web portal
CBBinding.init("Device ID", "Device Sig");
}
void OnApplicationPause(bool paused) {
// Manage Chartboost plugin lifecycle
CBBinding.pause(paused);
}
void OnDisable() {
// Shut down the Chartboost plugin
CBBinding.destroy();
}
public void Update() {
if (Input.GetKeyUp(KeyCode.Escape)) {
if (CBBinding.onBackPressed())
return;
else
Application.Quit();
}
}
}
Menu script that calls CBBinding.int
using UnityEngine;
using System.Collections;
using Chartboost;
public class Menu2 : MonoBehaviour {
private Ray ray;
private RaycastHit rayCastHit;
void Update ()
{
if(Input.GetMouseButtonDown(0))
{
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, out rayCastHit))
{
if (rayCastHit.transform.name == "PlayButton")
{
Application.LoadLevel("Main Game");
}
}
}
}
void Awake() {
CBBinding.showInterstitial(null);
}
}
Also: My Device ID and Sig is there soooo just for an FYI. If you could help thank you
Answer by tanuj0092 · Jun 03, 2014 at 10:21 PM
you are calling your ad in awake function. Chartboost is not initialized at that point. your implementation is correct though. But you are calling your ad quite early. Try calling your ad at some other point. (not in awake) such as a button click. It will surely work.
Just write a GUI Button in OnGUI() method and call CBBinding.showInterstitial( null ) on that button action. Check whether ad is being shown or not. And check the console for this.
void OnGUI()
{
if( GUI.Button( new Rect( 0,0,100,100), "Test Ad" ))
{
CBBinding.showInterstitial(null);
}
}
You could probably just change Awake() to Start(), looking at the code you have. It would probably give the desired behaviour.
@tanuj0092 - That works and it shows the gui button on the top left but still doesnt show like an Ad
@Tarlius - That doesnt work the ad doesnt display at all
Try again clicking that button and check your console. Check whether it is throwing any error or it would probably be logging the callbacks by the plug-ins. Also enable test mode of your chart boost account because this definitely displays the test ad.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Unity crashes when executing a script onMouseDown 1 Answer
Disply ad not calling in Device 0 Answers
A node in a childnode? 1 Answer
MonoDevelope is not opening! 1 Answer