import Flutter
import UIKit

@main
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
    let securityChannel = FlutterMethodChannel(name: "com.siro.siro_service/security",
                                              binaryMessenger: controller.binaryMessenger)
    
    securityChannel.setMethodCallHandler({
      (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
      if (call.method == "getAppSignature") {
        // For iOS, we use a high-entropy secure token (Shared Secret) 
        // that matches the one stored on the server environment.
        result("b9d8e7f1a2c3d4e5f607182930415263748596a7b8c9d0e1f2a3b4c5d6e7f809")
      } else if (call.method == "isNativeRooted") {
        // Basic check for iOS jailbreak can be added here if needed
        result(false) 
      } else {
        result(FlutterMethodNotImplemented)
      }
    })

    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

