Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Facebook Interstitial Ads error "Specified cast is not vailid"

$
0
0

I use DependencyService to implemement Interstitial Facebook Ads it's error

`public class FacebookIntertialsAds : IFacebookIntertialsAds
    {
        private InterstitialAd interstitialAd;
        private MyInterstitialAdListener listener ;
        public void ShowAds()
        {
            interstitialAd = new InterstitialAd(Application.Context, "ADS ID");
            interstitialAd.LoadAd();
            listener = new MyInterstitialAdListener(interstitialAd);
            interstitialAd.SetAdListener(listener);
        }
    }`

Listener
`public class MyInterstitialAdListener : IInterstitialAdListener
{
private InterstitialAd interstitialAd;

    public MyInterstitialAdListener(InterstitialAd interstitialAd)
    {
        this.interstitialAd = interstitialAd;
    }

    public void Dispose()
    {
        Debug.Write("");
    }

    public IntPtr Handle { get; }
    public void OnAdClicked(IAd p0)
    {
        Debug.Write("OnAdClicked");
    }

    public void OnAdLoaded(IAd p0)
    {
        Debug.Write("OnAdLoaded");
        interstitialAd.Show();
    }

    public void OnError(IAd p0, AdError p1)
    {
        Debug.Write("OnError");
    }

    public void OnLoggingImpression(IAd p0)
    {
        Debug.Write("OnLoggingImpression");
    }

    public void OnInterstitialDismissed(IAd p0)
    {
        Debug.Write("OnInterstitialDismissed");
    }

    public void OnInterstitialDisplayed(IAd p0)
    {
        Debug.Write("OnInterstitialDisplayed");
    }
}`

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>