Created
November 27, 2019 15:55
-
-
Save anka/1bd50315e7e611f08fe98a283c029733 to your computer and use it in GitHub Desktop.
iOS app delegate implementing a Flutter method channel for file sharing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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