dreamsoftin / facebook_audience_network

Flutter Facebook Audience Network
https://pub.dartlang.org/packages/facebook_audience_network/
MIT License
156 stars 99 forks source link

i Found bug in iOS. See below detailed resolution. #41

Closed dharmesh304 closed 4 years ago

dharmesh304 commented 4 years ago

File FacebookAudienceNetworkInterstitialAd.swift Line no:- 106 func interstitialAdDidClose(_ interstitialAd: FBInterstitialAd) { print("InterstitialAdView > interstitialAdDidClose") // You need to forgot dismissed event. //Here is the code you need to add let placement_id: String = interstitialAd.placementID let invalidated: Bool = interstitialAd.isAdValid let arg: [String: Any] = [ FANConstant.PLACEMENT_ID_ARG: placement_id, FANConstant.INVALIDATED_ARG: invalidated, ] self.channel.invokeMethod(FANConstant.DISMISSED_METHOD, arguments: arg) }

Second Bug Function Line No:- 48 func showAD(_ call: FlutterMethodCall) -> Bool { // You need to comment line no 56 in this function. because you wrote two time.it will cause error while displaying ads second time. because ad was not loaded. }

Resolved full function

`func showAD(_ call: FlutterMethodCall) -> Bool { if !self.interstitialAd.isAdValid { print("FacebookAudienceNetworkInterstitialAdPlugin > showAD > not AdVaild") return false } let args: NSDictionary = call.arguments as! NSDictionary let delay: Int = args["delay"] as! Int //MARK:- Need to remove because already called below using delay //self.interstitialAd.show(fromRootViewController: UIApplication.shared.keyWindow?.rootViewController)

    print("@@@ delay %d", delay)

    if 0 < delay {
        let time = DispatchTime.now() + .seconds(delay)
        DispatchQueue.main.asyncAfter(deadline: time) {
            self.interstitialAd.show(fromRootViewController: UIApplication.shared.keyWindow?.rootViewController)
        }
    } else {
        self.interstitialAd.show(fromRootViewController: UIApplication.shared.keyWindow?.rootViewController)
    }
    return true
}`
SachinGanesh commented 4 years ago

Thank you for letting us know. It would be great if you could raise a PR

dharmesh304 commented 4 years ago

I had raised a PR Please check.

SachinGanesh commented 4 years ago

Merged. Thank you for your contribution!