Skip to content

Instantly share code, notes, and snippets.

@anka
Created November 27, 2019 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anka/1bd50315e7e611f08fe98a283c029733 to your computer and use it in GitHub Desktop.
Save anka/1bd50315e7e611f08fe98a283c029733 to your computer and use it in GitHub Desktop.
iOS app delegate implementing a Flutter method channel for file sharing
@objc class AppDelegate: FlutterAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Receive the share method channel
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
let shareChannel = FlutterMethodChannel(name: "jademind.com/share", binaryMessenger: controller.binaryMessenger)
// Register a callback handler
shareChannel.setMethodCallHandler({
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
if (call.method == "share-file") {
self.shareFile(arguments: call.arguments);
}
})
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
// further implementation goes here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment