ConversionSDKFlutterPlugin.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. import Flutter
  2. import UIKit
  3. import ComPDFKit_Conversion
  4. public class ConversionSDKFlutterPlugin : NSObject, FlutterPlugin {
  5. public static func register(with registrar: FlutterPluginRegistrar) {
  6. let channel = FlutterMethodChannel(name: "com.compdfkit.conversion.flutter.convert.sdk.info", binaryMessenger: registrar.messenger())
  7. let instance = ConversionSDKFlutterPlugin()
  8. ConverFilePlugin(messenger: registrar.messenger())
  9. registrar.addMethodCallDelegate(instance, channel: channel)
  10. }
  11. public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
  12. print("method:\(call.method)");
  13. if (call.method == "conversion_init"){
  14. let initInfo = call.arguments as! [String: String];
  15. let key = initInfo["key"] ?? "";
  16. let secret = initInfo["secret"] ?? "";
  17. print("conversion metthod channel init")
  18. print("init key:\(key)");
  19. print("init secret:\(secret)");
  20. ComPDFKit_Conversion.CPDFConvertKit.setLicenseKey( key, secret: secret);
  21. result("true")
  22. } else if (call.method == "sdk_build_tag"){
  23. result(ComPDFKit_Conversion.CPDFConvertKit().versionString)
  24. } else if (call.method == "request_convert_output_path") {
  25. result(NSHomeDirectory() + "/Documents/ConversionDemo")
  26. } else if (call.method == "sdk_version"){
  27. result(ComPDFKit_Conversion.CPDFConvertKit().versionString)
  28. }
  29. }
  30. }