AppDelegate.swift 1.31 KB
import UIKit
import Flutter
import flutter_downloader

@main
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    let controller = self.window.rootViewController as! FlutterViewController
       let channel = FlutterMethodChannel.init(name: "com.naji/book", binaryMessenger: controller as! FlutterBinaryMessenger)
       channel.setMethodCallHandler { (call, result) in
           if call.method == "getIntent" {
              //  let para = call.arguments
              //  print(para!)
            let userInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification];
               
            result(userInfo);
           }else{
               result(FlutterMethodNotImplemented)
           }
       }
    GeneratedPluginRegistrant.register(with: self)
      FlutterDownloaderPlugin.setPluginRegistrantCallback(registerPlugins)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

private func registerPlugins(registry: FlutterPluginRegistry) {
    if (!registry.hasPlugin("FlutterDownloaderPlugin")) {
       FlutterDownloaderPlugin.register(with: registry.registrar(forPlugin: "FlutterDownloaderPlugin")!)
    }
}