Created
December 6, 2020 05:05
-
-
Save CoderJava/a92de4ca192a94257042531eb76509be to your computer and use it in GitHub Desktop.
AppDelegate.swift sample time zone flutter
This file contains hidden or 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
| import UIKit | |
| import Flutter | |
| @UIApplicationMain | |
| @objc class AppDelegate: FlutterAppDelegate { | |
| override func application( | |
| _ application: UIApplication, | |
| didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? | |
| ) -> Bool { | |
| GeneratedPluginRegistrant.register(with: self) | |
| let controller : FlutterViewController = window?.rootViewController as! FlutterViewController | |
| let channel = FlutterMethodChannel(name: "sample_time_zone_flutter_channel", binaryMessenger: controller.binaryMessenger) | |
| channel.setMethodCallHandler({(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in | |
| if (call.method == "get_native_time_zone") { | |
| let timezone = TimeZone.current | |
| let timezoneName = timezone.identifier | |
| let offsetFromUtc = timezone.secondsFromGMT() | |
| let resultMap: [String: Any] = ["timezone": timezoneName, "gmt_offset": offsetFromUtc] | |
| result(resultMap) | |
| } | |
| }) | |
| return super.application(application, didFinishLaunchingWithOptions: launchOptions) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment