Files
Hacki/components/synced_shared_preferences/ios/Classes/SwiftSyncedSharedPreferencesPlugin.swift
Jiaqi Feng ecc273c723 v0.2.5 (#17)
* updated icons.

* bumped version.

* fixed lint.

* added synced shared preferences package.

* fixed stories list view.

* updated LICENSE.

* fixed runtime err.

* updated README.md

* fixed color profile.

* added backward compatibility

* fixed version.

* updated pubspec.lock

* improved feature discovery flow. #16

* fixed shared prefs.

* bumped version.

* upgraded to Flutter 3.0

* added lock file.

* fixed time machine.

* added collapse cubit.

* bumped version.
2022-05-11 19:29:58 -07:00

58 lines
2.4 KiB
Swift

import Flutter
import UIKit
public class SwiftSyncedSharedPreferencesPlugin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "synced_shared_preferences", binaryMessenger: registrar.messenger())
let instance = SwiftSyncedSharedPreferencesPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
switch call.method {
case "setBool":
if let params = call.arguments as? [String: Any] {
let info: [String: Any] = ["result": result,
"params": params]
NotificationCenter.default.post(name: Notification.Name("setBool"), object: nil, userInfo: info)
}
return
case "getBool":
if let params = call.arguments as? [String: Any] {
let info: [String: Any] = ["result": result,
"params": params]
NotificationCenter.default.post(name: Notification.Name("getBool"), object: nil, userInfo: info)
}
return
case "setStringList":
if let params = call.arguments as? [String: Any] {
let info: [String: Any] = ["result": result,
"params": params]
NotificationCenter.default.post(name: Notification.Name("setStringList"), object: nil, userInfo: info)
}
return
case "getStringList":
if let params = call.arguments as? [String: Any] {
let info: [String: Any] = ["result": result,
"params": params]
NotificationCenter.default.post(name: Notification.Name("getStringList"), object: nil, userInfo: info)
}
return
case "clearAll":
if let params = call.arguments as? [String: Any] {
let info: [String: Any] = ["result": result,
"params": params]
NotificationCenter.default.post(name: Notification.Name("clearAll"), object: nil, userInfo: info)
}
return
default:
result(FlutterMethodNotImplemented)
}
}
}