Created
March 23, 2021 20:59
-
-
Save yaizudamashii/3a222c78ca3223ed2ce5e4b0b9e48157 to your computer and use it in GitHub Desktop.
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
import Flutter | |
import UIKit | |
class PrivacySettingViewController: UIViewController { | |
static let channelName: String = "your.app.identifier/privacy" // これはグローバルで他とかぶらない名前をつけます | |
// other functions ... | |
private func createFlutterChannel(_ flutterViewController: FlutterViewController) { | |
let privacyChannel = FlutterMethodChannel(name: channelName, binaryMessenger: flutterViewController.binaryMessenger) | |
privacyChannel.setMethodCallHandler({ (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in | |
guard call.method == "setPrivacyFlag" || call.method == "getPrivacyFlag" else { | |
result(FlutterMethodNotImplemented) | |
return | |
} | |
let privacyHandler = PrivacyHandler() | |
if call.method == "setPrivacyFlag" { | |
guard let isOn: Bool = (call.arguments as? [Any])?.first as? Bool else { | |
result(FlutterMethodNotImplemented) | |
return | |
} | |
privacyHandler.privacyFlag = isOn | |
result(isOn) | |
} | |
if call.method == "getPrivacyFlag" { | |
let isOn: Bool = privacyHandler.privacyFlag | |
result(isOn) | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment