Flutter ios原生开发添加广点通开屏广告,进入flutter后无法加载插件?

想要给项目添加开屏广告,但是没有广点通的相关插件,所以只能从原生那里入手。
想法是在进入flutter界面前,添加一个开屏,开屏结束后进入flutter
根据 https://github.com/gdtmobsdk/GDTMobSDK 配置好sdk后
仿照 https://github.com/gdtmobsdk/GDTMobSDK/blob/v4.11.1/GDTMobSample-Swift/AppDelegate.swift 写了自己的AppDelegate.swift 如下

出现的问题是,能够正常显示开屏广告,显示完毕后也能进入flutter,但是flutter所有的第三方插件全部失效,报错是没有找到插件。

AppDelegate.swift

import UIKit
import Flutter


@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
    var splash: GDTSplashAd!
    var flutterViewController: FlutterViewController?
    var flutterEngine : FlutterEngine?;


  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {

    GeneratedPluginRegistrant.register(with: self)

    self.flutterViewController = FlutterViewController()

    window = UIWindow.init(frame: UIScreen.main.bounds)
    let rootViewController = GDTNavigationController.init(rootViewController: self.flutterViewController!)
    rootViewController.navigationBar.isHidden = true
    rootViewController.navigationBar.isTranslucent = true

    window?.rootViewController = rootViewController
    window.makeKeyAndVisible()


    if UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.phone {
        splash = GDTSplashAd.init(appId: Constant.appID, placementId: Constant.placementID)
        splash.delegate = self as? GDTSplashAdDelegate

        var splashImage = UIImage(named: "SplashNormal-swift")
        if Util.isIphoneX() {
            splashImage = UIImage(named: "SplashX-swift")
        } else if Util.isSmallIphone() {
            splashImage = UIImage(named: "SplashSmall-swift")
        }
        splash.backgroundImage = splashImage
        splash.fetchDelay = 3
        splash.loadAndShow(in: window)
    }

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
}

为了方便查看贴上图片代码:
在这里插入图片描述

p.s flutter正常生成的代码(未改造前的):

import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值