nboy1 / Admob-for-Flash-ANE-GMA21-GLM-

Admob for Flash ANE GMA21 (GLM) "adobe air native extension"
6 stars 0 forks source link

There is no Interstitial AD in the Android #6

Open timxie-88 opened 9 months ago

timxie-88 commented 9 months ago

There is no error reported in the Android project but no Interstitial advertisement pops up.The ios is fine.

my code:

import com.glm.admob.*; public static const full_id:String = "ca-app-pub-5775104096289517/5840294824"; public static const appID:String = "ca-app-pub-5775104096289517~1162683210"; Admob.Ads().ShowAppOpen(appID); //Test with buttons as follows private function clickEventHandler(evt:MouseEvent):void{

        var ftr:String=evt.target.name
        var n:int = int(ftr.substr(-1,1))

        if(n==0){

        showAdmobFull(0)
       }
        else
      {
      showAdmobFull(1)
      }

     }

public function showAdmobFull(num:int):void { if (num == 1) {

              Admob.Ads().ShowInterstitial();

            }else {
                 Admob.Ads().LoadInterstitial(full_id);

            }
    }

//========== and xml like:

]]>

//==========extensionID=== <extensionID>com.glm.admob</extensionID> //============== Nothing is wrong except there are no ads

nboy1 commented 9 months ago

Hi, i think the error is in this part : var n:int = int(ftr.substr(-1,1)) because i think n will always be equal 0.

instead try this logic i think it's better because first time will load the Interstitial second time third ... will show Interstitial directly and if the Interstitial not loaded the ANE will automatically call load interstitial with ID you provided first time, so whenever you call this function it will show interstitial and if it is not loaded it will load it again automatically so you will have to call only Admob.Ads().ShowInterstitial();

Example: ....

import com.glm.admob.*;

public static const full_id:String = "ca-app-pub-5775104096289517/5840294824";
public static const appID:String = "ca-app-pub-5775104096289517~1162683210";

private var isFirstTime:Boolean = true; // Variable to track the first time the function is called

private function clickEventHandler(evt:MouseEvent):void{

        if (isFirstTime) {

            Admob.Ads().LoadInterstitial(full_id);
            isFirstTime = false; // Set isFirstTime to false after the first call so next calls will be always (else)

                                       } 
                               else {

            Admob.Ads().ShowInterstitial();

                                     }

     }
nboy1 commented 9 months ago

or better to profit from first click too:

import com.glm.admob.*;

public static const full_id:String = "ca-app-pub-5775104096289517/5840294824";
public static const appID:String = "ca-app-pub-5775104096289517~1162683210";

private var isFirstTime:Boolean = true; // Variable to track the first time the function is called

private function clickEventHandler(evt:MouseEvent):void{

        if (isFirstTime) {

            Admob.Ads().LoadInterstitial(full_id);
            isFirstTime = false; // Set isFirstTime to false after the first call so next calls will be always (else)

            showAdmobFull();  // call it first time too to profit from it if the Interstitial is loaded in the first call. 
                                       } 
                               else {

            Admob.Ads().ShowInterstitial();

                                     }

     }

public function showAdmobFull():void {
Admob.Ads().ShowInterstitial();

}
timxie-88 commented 9 months ago

Hi nboy1,Thank you so much for your reply. my buttons code below: btn_buy0.addEventListener(MouseEvent.MOUSE_DOWN, clickEventHandler) btn_buy1.addEventListener(MouseEvent.MOUSE_DOWN, clickEventHandler) i have test that is no wrong , and same code ios can show ads, android can't.

nboy1 commented 9 months ago

Hi , did you tried the new code i provided ? if you did not please try it, i just don't want to count on "n" value, i'm trying to help in debugging to see where the problem came from if you can't help me in this by the steps i really can't help. since there is no error i think the problem came from script or internet permission.

timxie-88 commented 9 months ago

Hi, I have tested the code you provided, but there are still no ads. Can you provide a program example so that I can pop up interstitial ads on Android? Thank you so much for everything you do, you are a great person and I wish you good luck every day.

nboy1 commented 9 months ago

Hi timxie-88, really thank you for your kind words, i hope you the same. thank you. i want you just to check this permissions if they are declared on your XML file if not just check on it.

image

i will try to create a demo app as soon as possible.

timxie-88 commented 9 months ago

Hi,nboy1,thank you so much,god blass you, I added : `

                <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
                <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
                <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>`

to the xml, but there are still no ads.

nboy1 commented 9 months ago

Hi @timxie-88 this is a sample Demo App, i made it for this ANE (FLA+.as+XML+SWF+APK) to test it and see how the code work. everything is working fine in this demo. i will try to Upgrade it to better later. https://github.com/nboy1/Admob-for-Flash-ANE-GMA21-GLM-/tree/main/DemoApp

nboy1 commented 9 months ago

GLM_Admob_ANE_demo_

timxie-88 commented 9 months ago

Hi nboy1,i have test your demo apk but still no Interstitial ad. I still have a question, how do I use the event listener when the Interstitial ad is closed or load fail? my code: Admob.Ads().addEventListener("AdDismissedFullScreenContent", onVideoEvent); Admob.Ads().addEventListener("AdFailedToLoad", onVideoEvent); public static function onVideoEvent(evt:Event):void { trace("=====================type=========================", evt.type); } but nothing hapeened

nboy1 commented 9 months ago

Hi, so then you have problem in your device "the mobile you are using to test apk", you didn't allow the app to use internet. so ads will not work as long as you are not allowing it. test the apk in other device. or install emulator to can test the apk.

timxie-88 commented 9 months ago

Hi,Thank you very much , maybe it's my mobile device problem, i will check my code。 Last question: How to use "Admob.Ads().addEventListener" to determine whether the ad is closed. I mean the event that is dispatched when the user clicks the "X" button in the ad?

Admob.Ads().addEventListener("AdLoaded", onVideoEvent); Admob.Ads().addEventListener("AdDismissedFullScreenContent", onVideoEvent); Admob.Ads().addEventListener("AdFailedToLoad", onVideoEvent); public static function onVideoEvent(evt:Event):void { trace("=====================type=========================", evt.type); } but nothing hapeen , I want to know what went wrong,please!

Thank you for everything. I really appreciate it. God will bless you. You are a good person.

nboy1 commented 9 months ago

thank you @timxie-88

this is the events :

public function onVideoEvent(evt:Event):void {
        if (evt.type == "UserEarnedReward") 
        {  
             //reward the user
        }
        if (evt.type == "AdShowedFullScreenContent") 
        {  

        }
        if (evt.type == "AdLoaded") 
        {  

        }
        if (evt.type == "AdFailedToLoad") 
        {  

        }
        if (evt.type == "AdFailedToShowFullScreenContent") 
        {  

        }
        if (evt.type == "AdDismissedFullScreenContent") 
        {  
             // the event that is dispatched when the user clicks the "X" button in the ad
        }

}
nboy1 commented 9 months ago

i've added Rewarded Events to the Demo https://github.com/nboy1/Admob-for-Flash-ANE-GMA21-GLM-/tree/main/DemoApp image

kalimaty commented 8 months ago

i've added Rewarded Events to the Demo https://github.com/nboy1/Admob-for-Flash-ANE-GMA21-GLM-/tree/main/DemoApp image

please i need your watsup pr telgram or email need your help please my 00201028130058 kalimaty6@gmail.com

nboy1 commented 7 months ago

@kalimaty i'm really sorry for being late in reply and too that i can't help, i've just started new business, i really can't find time even to my personal things, i'm too busy, me too i have 3 of my apps rejected from google play and i can't find time to update it and publish it again. just try to use chatgpt it will really helps you in all steps. sorry again.