Commit 945cfc3e authored by Mikkel Nygaard Ravn's avatar Mikkel Nygaard Ravn Committed by GitHub

Make naming consistent across channel APIs (#9270)

parent 752d6096
c24a0e51750570f271f860bbffbe082aab4ea72f 2a4434a058d0243447483101160c833029cb3654
...@@ -6,9 +6,9 @@ import android.support.design.widget.FloatingActionButton; ...@@ -6,9 +6,9 @@ import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import io.flutter.plugin.common.FlutterMessageChannel; import io.flutter.plugin.common.BasicMessageChannel;
import io.flutter.plugin.common.FlutterMessageChannel.MessageHandler; import io.flutter.plugin.common.BasicMessageChannel.MessageHandler;
import io.flutter.plugin.common.FlutterMessageChannel.Reply; import io.flutter.plugin.common.BasicMessageChannel.Reply;
import io.flutter.plugin.common.StringCodec; import io.flutter.plugin.common.StringCodec;
import io.flutter.view.FlutterMain; import io.flutter.view.FlutterMain;
import io.flutter.view.FlutterView; import io.flutter.view.FlutterView;
...@@ -20,7 +20,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -20,7 +20,7 @@ public class MainActivity extends AppCompatActivity {
private static final String CHANNEL = "increment"; private static final String CHANNEL = "increment";
private static final String EMPTY_MESSAGE = ""; private static final String EMPTY_MESSAGE = "";
private static final String PING = "ping"; private static final String PING = "ping";
private FlutterMessageChannel messageChannel; private BasicMessageChannel messageChannel;
private String[] getArgsFromIntent(Intent intent) { private String[] getArgsFromIntent(Intent intent) {
// Before adding more entries to this list, consider that arbitrary // Before adding more entries to this list, consider that arbitrary
...@@ -57,15 +57,13 @@ public class MainActivity extends AppCompatActivity { ...@@ -57,15 +57,13 @@ public class MainActivity extends AppCompatActivity {
flutterView = (FlutterView) findViewById(R.id.flutter_view); flutterView = (FlutterView) findViewById(R.id.flutter_view);
flutterView.runFromBundle(FlutterMain.findAppBundlePath(getApplicationContext()), null); flutterView.runFromBundle(FlutterMain.findAppBundlePath(getApplicationContext()), null);
messageChannel = messageChannel = new BasicMessageChannel<>(flutterView, CHANNEL, StringCodec.INSTANCE);
new FlutterMessageChannel<String>(flutterView, CHANNEL, StringCodec.INSTANCE);
messageChannel. messageChannel.
setMessageHandler(new MessageHandler<String>() { setMessageHandler(new MessageHandler<String>() {
@Override @Override
public void onMessage(String s, Reply<String> reply) { public void onMessage(String s, Reply<String> reply) {
onFlutterIncrement(); onFlutterIncrement();
reply.send(EMPTY_MESSAGE); reply.reply(EMPTY_MESSAGE);
} }
}); });
...@@ -108,4 +106,4 @@ public class MainActivity extends AppCompatActivity { ...@@ -108,4 +106,4 @@ public class MainActivity extends AppCompatActivity {
super.onPostResume(); super.onPostResume();
flutterView.onPostResume(); flutterView.onPostResume();
} }
} }
\ No newline at end of file
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
@property (nonatomic) NativeViewController* nativeViewController; @property (nonatomic) NativeViewController* nativeViewController;
@property (nonatomic) FlutterViewController* flutterViewController; @property (nonatomic) FlutterViewController* flutterViewController;
@property (nonatomic) FlutterMessageChannel* messageChannel; @property (nonatomic) FlutterBasicMessageChannel* messageChannel;
@end @end
static NSString* const emptyString = @""; static NSString* const emptyString = @"";
...@@ -35,20 +35,20 @@ static NSString* const channel = @"increment"; ...@@ -35,20 +35,20 @@ static NSString* const channel = @"increment";
if ([segue.identifier isEqualToString:@"FlutterViewControllerSegue"]) { if ([segue.identifier isEqualToString:@"FlutterViewControllerSegue"]) {
self.flutterViewController = segue.destinationViewController; self.flutterViewController = segue.destinationViewController;
self.messageChannel = [FlutterMessageChannel messageChannelWithName:channel self.messageChannel = [FlutterBasicMessageChannel messageChannelWithName:channel
binaryMessenger:self.flutterViewController binaryMessenger:self.flutterViewController
codec:[FlutterStringCodec sharedInstance]]; codec:[FlutterStringCodec sharedInstance]];
MainViewController* __weak weakSelf = self; MainViewController* __weak weakSelf = self;
[self.messageChannel setMessageHandler:^(id message, FlutterReplyHandler replyHandler) { [self.messageChannel setMessageHandler:^(id message, FlutterReply reply) {
[weakSelf.nativeViewController didReceiveIncrement]; [weakSelf.nativeViewController didReceiveIncrement];
replyHandler(emptyString); reply(emptyString);
}]; }];
} }
} }
- (void)didTapIncrementButton { - (void)didTapIncrementButton {
[self.messageChannel sendMessage:ping replyHandler:nil]; [self.messageChannel sendMessage:ping];
} }
@end @end
...@@ -29,8 +29,8 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -29,8 +29,8 @@ class _MyHomePageState extends State<MyHomePage> {
static const String _channel = "increment"; static const String _channel = "increment";
static const String _pong = "pong"; static const String _pong = "pong";
static const String _emptyMessage = ""; static const String _emptyMessage = "";
static const PlatformMessageChannel<String> platform = static const BasicMessageChannel<String> platform =
const PlatformMessageChannel<String>(_channel, const StringCodec()); const BasicMessageChannel<String>(_channel, const StringCodec());
int _counter = 0; int _counter = 0;
......
...@@ -15,12 +15,12 @@ import android.os.Build.VERSION_CODES; ...@@ -15,12 +15,12 @@ import android.os.Build.VERSION_CODES;
import android.os.Bundle; import android.os.Bundle;
import io.flutter.app.FlutterActivity; import io.flutter.app.FlutterActivity;
import io.flutter.plugin.common.FlutterEventChannel; import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.FlutterEventChannel.EventSink; import io.flutter.plugin.common.EventChannel.EventSink;
import io.flutter.plugin.common.FlutterEventChannel.StreamHandler; import io.flutter.plugin.common.EventChannel.StreamHandler;
import io.flutter.plugin.common.FlutterMethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.FlutterMethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.FlutterMethodChannel.Response; import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
public class MainActivity extends FlutterActivity { public class MainActivity extends FlutterActivity {
...@@ -31,7 +31,7 @@ public class MainActivity extends FlutterActivity { ...@@ -31,7 +31,7 @@ public class MainActivity extends FlutterActivity {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
new FlutterEventChannel(getFlutterView(), CHARGING_CHANNEL).setStreamHandler( new EventChannel(getFlutterView(), CHARGING_CHANNEL).setStreamHandler(
new StreamHandler() { new StreamHandler() {
private BroadcastReceiver chargingStateChangeReceiver; private BroadcastReceiver chargingStateChangeReceiver;
@Override @Override
...@@ -49,20 +49,20 @@ public class MainActivity extends FlutterActivity { ...@@ -49,20 +49,20 @@ public class MainActivity extends FlutterActivity {
} }
); );
new FlutterMethodChannel(getFlutterView(), BATTERY_CHANNEL).setMethodCallHandler( new MethodChannel(getFlutterView(), BATTERY_CHANNEL).setMethodCallHandler(
new MethodCallHandler() { new MethodCallHandler() {
@Override @Override
public void onMethodCall(MethodCall call, Response response) { public void onMethodCall(MethodCall call, Result result) {
if (call.method.equals("getBatteryLevel")) { if (call.method.equals("getBatteryLevel")) {
int batteryLevel = getBatteryLevel(); int batteryLevel = getBatteryLevel();
if (batteryLevel != -1) { if (batteryLevel != -1) {
response.success(batteryLevel); result.success(batteryLevel);
} else { } else {
response.error("UNAVAILABLE", "Battery level not available.", null); result.error("UNAVAILABLE", "Battery level not available.", null);
} }
} else { } else {
response.notImplemented(); result.notImplemented();
} }
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
@implementation AppDelegate { @implementation AppDelegate {
FlutterEventReceiver _eventReceiver; FlutterEventSink _eventSink;
} }
- (BOOL)application:(UIApplication*)application - (BOOL)application:(UIApplication*)application
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
methodChannelWithName:@"samples.flutter.io/battery" methodChannelWithName:@"samples.flutter.io/battery"
binaryMessenger:controller]; binaryMessenger:controller];
[batteryChannel setMethodCallHandler:^(FlutterMethodCall* call, [batteryChannel setMethodCallHandler:^(FlutterMethodCall* call,
FlutterResultReceiver result) { FlutterResult result) {
if ([@"getBatteryLevel" isEqualToString:call.method]) { if ([@"getBatteryLevel" isEqualToString:call.method]) {
int batteryLevel = [self getBatteryLevel]; int batteryLevel = [self getBatteryLevel];
if (batteryLevel == -1) { if (batteryLevel == -1) {
...@@ -52,8 +52,8 @@ ...@@ -52,8 +52,8 @@
} }
- (FlutterError*)onListenWithArguments:(id)arguments - (FlutterError*)onListenWithArguments:(id)arguments
eventReceiver:(FlutterEventReceiver)eventReceiver { eventSink:(FlutterEventSink)eventSink {
_eventReceiver = eventReceiver; _eventSink = eventSink;
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES]; [[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
[self sendBatteryStateEvent]; [self sendBatteryStateEvent];
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
...@@ -74,22 +74,22 @@ ...@@ -74,22 +74,22 @@
switch (state) { switch (state) {
case UIDeviceBatteryStateFull: case UIDeviceBatteryStateFull:
case UIDeviceBatteryStateCharging: case UIDeviceBatteryStateCharging:
_eventReceiver(@"charging"); _eventSink(@"charging");
break; break;
case UIDeviceBatteryStateUnplugged: case UIDeviceBatteryStateUnplugged:
_eventReceiver(@"discharging"); _eventSink(@"discharging");
break; break;
default: default:
_eventReceiver([FlutterError errorWithCode:@"UNAVAILABLE" _eventSink([FlutterError errorWithCode:@"UNAVAILABLE"
message:@"Charging status unavailable" message:@"Charging status unavailable"
details:nil]); details:nil]);
break; break;
} }
} }
- (FlutterError*)onCancelWithArguments:(id)arguments { - (FlutterError*)onCancelWithArguments:(id)arguments {
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self];
_eventReceiver = nil; _eventSink = nil;
return nil; return nil;
} }
......
...@@ -13,10 +13,10 @@ class PlatformChannel extends StatefulWidget { ...@@ -13,10 +13,10 @@ class PlatformChannel extends StatefulWidget {
} }
class _PlatformChannelState extends State<PlatformChannel> { class _PlatformChannelState extends State<PlatformChannel> {
static const PlatformMethodChannel methodChannel = static const MethodChannel methodChannel =
const PlatformMethodChannel('samples.flutter.io/battery'); const MethodChannel('samples.flutter.io/battery');
static const PlatformEventChannel eventChannel = static const EventChannel eventChannel =
const PlatformEventChannel('samples.flutter.io/charging'); const EventChannel('samples.flutter.io/charging');
String _batteryLevel = 'Battery level: unknown.'; String _batteryLevel = 'Battery level: unknown.';
String _chargingStatus = 'Battery status: unknown.'; String _chargingStatus = 'Battery status: unknown.';
......
...@@ -7,7 +7,7 @@ import Flutter ...@@ -7,7 +7,7 @@ import Flutter
@UIApplicationMain @UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate, FlutterStreamHandler { @objc class AppDelegate: FlutterAppDelegate, FlutterStreamHandler {
private var eventReceiver: FlutterEventReceiver?; private var eventSink: FlutterEventSink?;
override func application( override func application(
_ application: UIApplication, _ application: UIApplication,
...@@ -16,14 +16,13 @@ import Flutter ...@@ -16,14 +16,13 @@ import Flutter
let batteryChannel = FlutterMethodChannel.init(name: "samples.flutter.io/battery", let batteryChannel = FlutterMethodChannel.init(name: "samples.flutter.io/battery",
binaryMessenger: controller); binaryMessenger: controller);
batteryChannel.setMethodCallHandler({ batteryChannel.setMethodCallHandler({
(call: FlutterMethodCall, result: FlutterResultReceiver) -> Void in (call: FlutterMethodCall, result: FlutterResult) -> Void in
if ("getBatteryLevel" == call.method) { if ("getBatteryLevel" == call.method) {
self.receiveBatteryLevel(result: result); self.receiveBatteryLevel(result: result);
} else { } else {
result(FlutterMethodNotImplemented); result(FlutterMethodNotImplemented);
} }
} });
);
let chargingChannel = FlutterEventChannel.init(name: "samples.flutter.io/charging", let chargingChannel = FlutterEventChannel.init(name: "samples.flutter.io/charging",
binaryMessenger: controller); binaryMessenger: controller);
...@@ -31,7 +30,7 @@ import Flutter ...@@ -31,7 +30,7 @@ import Flutter
return true return true
} }
private func receiveBatteryLevel(result: FlutterResultReceiver) { private func receiveBatteryLevel(result: FlutterResult) {
let device = UIDevice.current; let device = UIDevice.current;
device.isBatteryMonitoringEnabled = true; device.isBatteryMonitoringEnabled = true;
if (device.batteryState == UIDeviceBatteryState.unknown) { if (device.batteryState == UIDeviceBatteryState.unknown) {
...@@ -44,8 +43,8 @@ import Flutter ...@@ -44,8 +43,8 @@ import Flutter
} }
public func onListen(withArguments arguments: Any?, public func onListen(withArguments arguments: Any?,
eventReceiver: @escaping FlutterEventReceiver) -> FlutterError? { eventSink: @escaping FlutterEventSink) -> FlutterError? {
self.eventReceiver = eventReceiver; self.eventSink = eventSink;
UIDevice.current.isBatteryMonitoringEnabled = true; UIDevice.current.isBatteryMonitoringEnabled = true;
self.sendBatteryStateEvent(); self.sendBatteryStateEvent();
NotificationCenter.default.addObserver( NotificationCenter.default.addObserver(
...@@ -61,32 +60,32 @@ import Flutter ...@@ -61,32 +60,32 @@ import Flutter
} }
private func sendBatteryStateEvent() { private func sendBatteryStateEvent() {
if (eventReceiver == nil) { if (eventSink == nil) {
return; return;
} }
let state = UIDevice.current.batteryState; let state = UIDevice.current.batteryState;
switch state { switch state {
case UIDeviceBatteryState.full: case UIDeviceBatteryState.full:
eventReceiver!("charging"); eventSink!("charging");
break; break;
case UIDeviceBatteryState.charging: case UIDeviceBatteryState.charging:
eventReceiver!("charging"); eventSink!("charging");
break; break;
case UIDeviceBatteryState.unplugged: case UIDeviceBatteryState.unplugged:
eventReceiver!("discharging"); eventSink!("discharging");
break; break;
default: default:
eventReceiver!(FlutterError.init(code: "UNAVAILABLE", eventSink!(FlutterError.init(code: "UNAVAILABLE",
message: "Charging status unavailable", message: "Charging status unavailable",
details: nil)); details: nil));
break; break;
} }
} }
public func onCancel(withArguments arguments: Any?) -> FlutterError? { public func onCancel(withArguments arguments: Any?) -> FlutterError? {
NotificationCenter.default.removeObserver(self); NotificationCenter.default.removeObserver(self);
eventReceiver = nil; eventSink = nil;
return nil; return nil;
} }
} }
...@@ -13,10 +13,10 @@ class PlatformChannel extends StatefulWidget { ...@@ -13,10 +13,10 @@ class PlatformChannel extends StatefulWidget {
} }
class _PlatformChannelState extends State<PlatformChannel> { class _PlatformChannelState extends State<PlatformChannel> {
static const PlatformMethodChannel methodChannel = static const MethodChannel methodChannel =
const PlatformMethodChannel('samples.flutter.io/battery'); const MethodChannel('samples.flutter.io/battery');
static const PlatformEventChannel eventChannel = static const EventChannel eventChannel =
const PlatformEventChannel('samples.flutter.io/charging'); const EventChannel('samples.flutter.io/charging');
String _batteryLevel = 'Battery level: unknown.'; String _batteryLevel = 'Battery level: unknown.';
String _chargingStatus = 'Battery status: unknown.'; String _chargingStatus = 'Battery status: unknown.';
......
...@@ -216,7 +216,7 @@ class PlatformAssetBundle extends CachingAssetBundle { ...@@ -216,7 +216,7 @@ class PlatformAssetBundle extends CachingAssetBundle {
Future<ByteData> load(String key) async { Future<ByteData> load(String key) async {
final Uint8List encoded = UTF8.encoder.convert(key); final Uint8List encoded = UTF8.encoder.convert(key);
final ByteData asset = final ByteData asset =
await PlatformMessages.sendBinary('flutter/assets', encoded.buffer.asByteData()); await BinaryMessages.send('flutter/assets', encoded.buffer.asByteData());
if (asset == null) if (asset == null)
throw new FlutterError('Unable to load asset: $key'); throw new FlutterError('Unable to load asset: $key');
return asset; return asset;
......
...@@ -11,7 +11,7 @@ import 'asset_bundle.dart'; ...@@ -11,7 +11,7 @@ import 'asset_bundle.dart';
import 'image_cache.dart'; import 'image_cache.dart';
import 'platform_messages.dart'; import 'platform_messages.dart';
/// Listens for platform messages and directs them to [PlatformMessages]. /// Listens for platform messages and directs them to [BinaryMessages].
/// ///
/// The ServicesBinding also registers a [LicenseEntryCollector] that exposes /// The ServicesBinding also registers a [LicenseEntryCollector] that exposes
/// the licenses found in the `LICENSE` file stored at the root of the asset /// the licenses found in the `LICENSE` file stored at the root of the asset
...@@ -21,7 +21,7 @@ abstract class ServicesBinding extends BindingBase { ...@@ -21,7 +21,7 @@ abstract class ServicesBinding extends BindingBase {
void initInstances() { void initInstances() {
super.initInstances(); super.initInstances();
ui.window ui.window
..onPlatformMessage = PlatformMessages.handlePlatformMessage; ..onPlatformMessage = BinaryMessages.handlePlatformMessage;
LicenseRegistry.addLicense(_addLicenses); LicenseRegistry.addLicense(_addLicenses);
} }
......
...@@ -27,11 +27,11 @@ import 'platform_messages.dart'; ...@@ -27,11 +27,11 @@ import 'platform_messages.dart';
/// time. /// time.
/// ///
/// See: <https://flutter.io/platform-channels/> /// See: <https://flutter.io/platform-channels/>
class PlatformMessageChannel<T> { class BasicMessageChannel<T> {
/// Creates a [PlatformMessageChannel] with the specified [name] and [codec]. /// Creates a [BasicMessageChannel] with the specified [name] and [codec].
/// ///
/// Neither [name] nor [codec] may be `null`. /// Neither [name] nor [codec] may be `null`.
const PlatformMessageChannel(this.name, this.codec); const BasicMessageChannel(this.name, this.codec);
/// The logical channel on which communication happens, not `null`. /// The logical channel on which communication happens, not `null`.
final String name; final String name;
...@@ -45,7 +45,7 @@ class PlatformMessageChannel<T> { ...@@ -45,7 +45,7 @@ class PlatformMessageChannel<T> {
/// or to a [FormatException], if encoding or decoding fails. /// or to a [FormatException], if encoding or decoding fails.
Future<T> send(T message) async { Future<T> send(T message) async {
return codec.decodeMessage( return codec.decodeMessage(
await PlatformMessages.sendBinary(name, codec.encodeMessage(message)) await BinaryMessages.send(name, codec.encodeMessage(message))
); );
} }
...@@ -60,9 +60,9 @@ class PlatformMessageChannel<T> { ...@@ -60,9 +60,9 @@ class PlatformMessageChannel<T> {
/// plugins as a response. /// plugins as a response.
void setMessageHandler(Future<T> handler(T message)) { void setMessageHandler(Future<T> handler(T message)) {
if (handler == null) { if (handler == null) {
PlatformMessages.setBinaryMessageHandler(name, null); BinaryMessages.setMessageHandler(name, null);
} else { } else {
PlatformMessages.setBinaryMessageHandler(name, (ByteData message) async { BinaryMessages.setMessageHandler(name, (ByteData message) async {
return codec.encodeMessage(await handler(codec.decodeMessage(message))); return codec.encodeMessage(await handler(codec.decodeMessage(message)));
}); });
} }
...@@ -80,9 +80,9 @@ class PlatformMessageChannel<T> { ...@@ -80,9 +80,9 @@ class PlatformMessageChannel<T> {
/// sent to platform plugins. /// sent to platform plugins.
void setMockMessageHandler(Future<T> handler(T message)) { void setMockMessageHandler(Future<T> handler(T message)) {
if (handler == null) { if (handler == null) {
PlatformMessages.setMockBinaryMessageHandler(name, null); BinaryMessages.setMockMessageHandler(name, null);
} else { } else {
PlatformMessages.setMockBinaryMessageHandler(name, (ByteData message) async { BinaryMessages.setMockMessageHandler(name, (ByteData message) async {
return codec.encodeMessage(await handler(codec.decodeMessage(message))); return codec.encodeMessage(await handler(codec.decodeMessage(message)));
}); });
} }
...@@ -103,14 +103,14 @@ class PlatformMessageChannel<T> { ...@@ -103,14 +103,14 @@ class PlatformMessageChannel<T> {
/// with may interfere with this channel's communication. /// with may interfere with this channel's communication.
/// ///
/// See: <https://flutter.io/platform-channels/> /// See: <https://flutter.io/platform-channels/>
class PlatformMethodChannel { class MethodChannel {
/// Creates a [PlatformMethodChannel] with the specified [name]. /// Creates a [MethodChannel] with the specified [name].
/// ///
/// The [codec] used will be [StandardMethodCodec], unless otherwise /// The [codec] used will be [StandardMethodCodec], unless otherwise
/// specified. /// specified.
/// ///
/// Neither [name] nor [codec] may be `null`. /// Neither [name] nor [codec] may be `null`.
const PlatformMethodChannel(this.name, [this.codec = const StandardMethodCodec()]); const MethodChannel(this.name, [this.codec = const StandardMethodCodec()]);
/// The logical channel on which communication happens, not `null`. /// The logical channel on which communication happens, not `null`.
final String name; final String name;
...@@ -128,7 +128,7 @@ class PlatformMethodChannel { ...@@ -128,7 +128,7 @@ class PlatformMethodChannel {
/// * a [MissingPluginException], if the method has not been implemented. /// * a [MissingPluginException], if the method has not been implemented.
Future<dynamic> invokeMethod(String method, [dynamic arguments]) async { Future<dynamic> invokeMethod(String method, [dynamic arguments]) async {
assert(method != null); assert(method != null);
final dynamic result = await PlatformMessages.sendBinary( final dynamic result = await BinaryMessages.send(
name, name,
codec.encodeMethodCall(new MethodCall(method, arguments)), codec.encodeMethodCall(new MethodCall(method, arguments)),
); );
...@@ -152,9 +152,9 @@ class PlatformMethodChannel { ...@@ -152,9 +152,9 @@ class PlatformMethodChannel {
/// similarly to what happens if no method call handler has been set. /// similarly to what happens if no method call handler has been set.
void setMethodCallHandler(Future<dynamic> handler(MethodCall call)) { void setMethodCallHandler(Future<dynamic> handler(MethodCall call)) {
if (handler == null) { if (handler == null) {
PlatformMessages.setBinaryMessageHandler(name, null); BinaryMessages.setMessageHandler(name, null);
} else { } else {
PlatformMessages.setBinaryMessageHandler( BinaryMessages.setMessageHandler(
name, name,
(ByteData message) async { (ByteData message) async {
final MethodCall call = codec.decodeMethodCall(message); final MethodCall call = codec.decodeMethodCall(message);
...@@ -187,9 +187,9 @@ class PlatformMethodChannel { ...@@ -187,9 +187,9 @@ class PlatformMethodChannel {
/// not sent to platform plugins. /// not sent to platform plugins.
void setMockMethodCallHandler(Future<dynamic> handler(MethodCall call)) { void setMockMethodCallHandler(Future<dynamic> handler(MethodCall call)) {
if (handler == null) { if (handler == null) {
PlatformMessages.setMockBinaryMessageHandler(name, null); BinaryMessages.setMockMessageHandler(name, null);
} else { } else {
PlatformMessages.setMockBinaryMessageHandler( BinaryMessages.setMockMessageHandler(
name, name,
(ByteData message) async { (ByteData message) async {
final MethodCall call = codec.decodeMethodCall(message); final MethodCall call = codec.decodeMethodCall(message);
...@@ -208,13 +208,13 @@ class PlatformMethodChannel { ...@@ -208,13 +208,13 @@ class PlatformMethodChannel {
} }
} }
/// A [PlatformMethodChannel] that ignores missing platform plugins. /// A [MethodChannel] that ignores missing platform plugins.
/// ///
/// When [invokeMethod] fails to find the platform plugin, it returns null /// When [invokeMethod] fails to find the platform plugin, it returns null
/// instead of throwing an exception. /// instead of throwing an exception.
class OptionalPlatformMethodChannel extends PlatformMethodChannel { class OptionalMethodChannel extends MethodChannel {
/// Creates a [PlatformMethodChannel] that ignores missing platform plugins. /// Creates a [MethodChannel] that ignores missing platform plugins.
const OptionalPlatformMethodChannel(String name, [MethodCodec codec = const StandardMethodCodec()]) const OptionalMethodChannel(String name, [MethodCodec codec = const StandardMethodCodec()])
: super(name, codec); : super(name, codec);
@override @override
...@@ -240,14 +240,14 @@ class OptionalPlatformMethodChannel extends PlatformMethodChannel { ...@@ -240,14 +240,14 @@ class OptionalPlatformMethodChannel extends PlatformMethodChannel {
/// with may interfere with this channel's communication. /// with may interfere with this channel's communication.
/// ///
/// See: <https://flutter.io/platform-channels/> /// See: <https://flutter.io/platform-channels/>
class PlatformEventChannel { class EventChannel {
/// Creates a [PlatformEventChannel] with the specified [name]. /// Creates a [EventChannel] with the specified [name].
/// ///
/// The [codec] used will be [StandardMethodCodec], unless otherwise /// The [codec] used will be [StandardMethodCodec], unless otherwise
/// specified. /// specified.
/// ///
/// Neither [name] nor [codec] may be `null`. /// Neither [name] nor [codec] may be `null`.
const PlatformEventChannel(this.name, [this.codec = const StandardMethodCodec()]); const EventChannel(this.name, [this.codec = const StandardMethodCodec()]);
/// The logical channel on which communication happens, not `null`. /// The logical channel on which communication happens, not `null`.
final String name; final String name;
...@@ -272,7 +272,7 @@ class PlatformEventChannel { ...@@ -272,7 +272,7 @@ class PlatformEventChannel {
/// Notes for platform plugin implementers: /// Notes for platform plugin implementers:
/// ///
/// Plugins must expose methods named `listen` and `cancel` suitable for /// Plugins must expose methods named `listen` and `cancel` suitable for
/// invocations by [PlatformMethodChannel.invokeMethod]. Both methods are /// invocations by [MethodChannel.invokeMethod]. Both methods are
/// invoked with the specified [arguments]. /// invoked with the specified [arguments].
/// ///
/// Following the semantics of broadcast streams, `listen` will be called as /// Following the semantics of broadcast streams, `listen` will be called as
...@@ -281,11 +281,11 @@ class PlatformEventChannel { ...@@ -281,11 +281,11 @@ class PlatformEventChannel {
/// indefinitely. Platform plugins should consume no stream-related resources /// indefinitely. Platform plugins should consume no stream-related resources
/// while listener count is zero. /// while listener count is zero.
Stream<dynamic> receiveBroadcastStream([dynamic arguments]) { Stream<dynamic> receiveBroadcastStream([dynamic arguments]) {
final PlatformMethodChannel methodChannel = new PlatformMethodChannel(name, codec); final MethodChannel methodChannel = new MethodChannel(name, codec);
StreamController<dynamic> controller; StreamController<dynamic> controller;
controller = new StreamController<dynamic>.broadcast( controller = new StreamController<dynamic>.broadcast(
onListen: () async { onListen: () async {
PlatformMessages.setBinaryMessageHandler( BinaryMessages.setMessageHandler(
name, (ByteData reply) async { name, (ByteData reply) async {
if (reply == null) { if (reply == null) {
controller.close(); controller.close();
...@@ -301,11 +301,11 @@ class PlatformEventChannel { ...@@ -301,11 +301,11 @@ class PlatformEventChannel {
try { try {
await methodChannel.invokeMethod('listen', arguments); await methodChannel.invokeMethod('listen', arguments);
} catch (e) { } catch (e) {
PlatformMessages.setBinaryMessageHandler(name, null); BinaryMessages.setMessageHandler(name, null);
controller.addError(e); controller.addError(e);
} }
}, onCancel: () async { }, onCancel: () async {
PlatformMessages.setBinaryMessageHandler(name, null); BinaryMessages.setMessageHandler(name, null);
try { try {
await methodChannel.invokeMethod('cancel', arguments); await methodChannel.invokeMethod('cancel', arguments);
} catch (exception, stack) { } catch (exception, stack) {
......
...@@ -8,29 +8,29 @@ import 'dart:ui' as ui; ...@@ -8,29 +8,29 @@ import 'dart:ui' as ui;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
typedef Future<ByteData> _PlatformMessageHandler(ByteData message); typedef Future<ByteData> _MessageHandler(ByteData message);
/// Sends binary messages to and receives binary messages from platform plugins. /// Sends binary messages to and receives binary messages from platform plugins.
/// ///
/// See also: /// See also:
/// ///
/// * [PlatformMessageChannel], which provides messaging services similar to /// * [BasicMessageChannel], which provides messaging services similar to
/// PlatformMessages, but with pluggable message codecs in support of sending /// [BinaryMessages], but with pluggable message codecs in support of sending
/// strings or semi-structured messages. /// strings or semi-structured messages.
/// * [PlatformMethodChannel], which provides higher-level platform /// * [MethodChannel], which provides higher-level platform
/// communication such as method invocations and event streams. /// communication such as method invocations and event streams.
/// ///
/// See: <https://flutter.io/platform-channels/> /// See: <https://flutter.io/platform-channels/>
class PlatformMessages { class BinaryMessages {
PlatformMessages._(); BinaryMessages._();
// Handlers for incoming messages from platform plugins. // Handlers for incoming messages from platform plugins.
static final Map<String, _PlatformMessageHandler> _handlers = static final Map<String, _MessageHandler> _handlers =
<String, _PlatformMessageHandler>{}; <String, _MessageHandler>{};
// Mock handlers that intercept and respond to outgoing messages. // Mock handlers that intercept and respond to outgoing messages.
static final Map<String, _PlatformMessageHandler> _mockHandlers = static final Map<String, _MessageHandler> _mockHandlers =
<String, _PlatformMessageHandler>{}; <String, _MessageHandler>{};
static Future<ByteData> _sendPlatformMessage(String channel, ByteData message) { static Future<ByteData> _sendPlatformMessage(String channel, ByteData message) {
final Completer<ByteData> completer = new Completer<ByteData>(); final Completer<ByteData> completer = new Completer<ByteData>();
...@@ -59,7 +59,7 @@ class PlatformMessages { ...@@ -59,7 +59,7 @@ class PlatformMessages {
String channel, ByteData data, ui.PlatformMessageResponseCallback callback) async { String channel, ByteData data, ui.PlatformMessageResponseCallback callback) async {
ByteData response; ByteData response;
try { try {
final _PlatformMessageHandler handler = _handlers[channel]; final _MessageHandler handler = _handlers[channel];
if (handler != null) if (handler != null)
response = await handler(data); response = await handler(data);
} catch (exception, stack) { } catch (exception, stack) {
...@@ -78,8 +78,8 @@ class PlatformMessages { ...@@ -78,8 +78,8 @@ class PlatformMessages {
/// ///
/// Returns a [Future] which completes to the received response, undecoded, in /// Returns a [Future] which completes to the received response, undecoded, in
/// binary form. /// binary form.
static Future<ByteData> sendBinary(String channel, ByteData message) { static Future<ByteData> send(String channel, ByteData message) {
final _PlatformMessageHandler handler = _mockHandlers[channel]; final _MessageHandler handler = _mockHandlers[channel];
if (handler != null) if (handler != null)
return handler(message); return handler(message);
return _sendPlatformMessage(channel, message); return _sendPlatformMessage(channel, message);
...@@ -93,7 +93,7 @@ class PlatformMessages { ...@@ -93,7 +93,7 @@ class PlatformMessages {
/// argument. /// argument.
/// ///
/// The handler's return value, if non-null, is sent as a response, unencoded. /// The handler's return value, if non-null, is sent as a response, unencoded.
static void setBinaryMessageHandler(String channel, Future<ByteData> handler(ByteData message)) { static void setMessageHandler(String channel, Future<ByteData> handler(ByteData message)) {
if (handler == null) if (handler == null)
_handlers.remove(channel); _handlers.remove(channel);
else else
...@@ -111,7 +111,7 @@ class PlatformMessages { ...@@ -111,7 +111,7 @@ class PlatformMessages {
/// ///
/// This is intended for testing. Messages intercepted in this manner are not /// This is intended for testing. Messages intercepted in this manner are not
/// sent to platform plugins. /// sent to platform plugins.
static void setMockBinaryMessageHandler(String channel, Future<ByteData> handler(ByteData message)) { static void setMockMessageHandler(String channel, Future<ByteData> handler(ByteData message)) {
if (handler == null) if (handler == null)
_mockHandlers.remove(channel); _mockHandlers.remove(channel);
else else
......
...@@ -9,42 +9,42 @@ import 'platform_channel.dart'; ...@@ -9,42 +9,42 @@ import 'platform_channel.dart';
class SystemChannels { class SystemChannels {
SystemChannels._(); SystemChannels._();
/// A JSON [PlatformMethodChannel] for navigation. /// A JSON [MethodChannel] for navigation.
static const PlatformMethodChannel navigation = const PlatformMethodChannel( static const MethodChannel navigation = const MethodChannel(
'flutter/navigation', 'flutter/navigation',
const JSONMethodCodec(), const JSONMethodCodec(),
); );
/// A JSON [PlatformMethodChannel] for invoking miscellaneous platform methods. /// A JSON [MethodChannel] for invoking miscellaneous platform methods.
/// ///
/// Ignores missing plugins. /// Ignores missing plugins.
static const PlatformMethodChannel platform = const OptionalPlatformMethodChannel( static const MethodChannel platform = const OptionalMethodChannel(
'flutter/platform', 'flutter/platform',
const JSONMethodCodec(), const JSONMethodCodec(),
); );
/// A JSON [PlatformMethodChannel] for handling text input. /// A JSON [MethodChannel] for handling text input.
/// ///
/// Ignores missing plugins. /// Ignores missing plugins.
static const PlatformMethodChannel textInput = const OptionalPlatformMethodChannel( static const MethodChannel textInput = const OptionalMethodChannel(
'flutter/textinput', 'flutter/textinput',
const JSONMethodCodec(), const JSONMethodCodec(),
); );
/// A JSON [PlatformMessageChannel] for key events. /// A JSON [BasicMessageChannel] for key events.
static const PlatformMessageChannel<dynamic> keyEvent = const PlatformMessageChannel<dynamic>( static const BasicMessageChannel<dynamic> keyEvent = const BasicMessageChannel<dynamic>(
'flutter/keyevent', 'flutter/keyevent',
const JSONMessageCodec(), const JSONMessageCodec(),
); );
/// A string [PlatformMessageChannel] for lifecycle events. /// A string [BasicMessageChannel] for lifecycle events.
static const PlatformMessageChannel<String> lifecycle = const PlatformMessageChannel<String>( static const BasicMessageChannel<String> lifecycle = const BasicMessageChannel<String>(
'flutter/lifecycle', 'flutter/lifecycle',
const StringCodec(), const StringCodec(),
); );
/// A JSON [PlatformMessageChannel] for system events. /// A JSON [BasicMessageChannel] for system events.
static const PlatformMessageChannel<dynamic> system = const PlatformMessageChannel<dynamic>( static const BasicMessageChannel<dynamic> system = const BasicMessageChannel<dynamic>(
'flutter/system', 'flutter/system',
const JSONMessageCodec(), const JSONMessageCodec(),
); );
......
...@@ -195,7 +195,7 @@ void main() { ...@@ -195,7 +195,7 @@ void main() {
bool completed; bool completed;
completed = false; completed = false;
PlatformMessages.setMockBinaryMessageHandler('flutter/assets', (ByteData message) async { BinaryMessages.setMockMessageHandler('flutter/assets', (ByteData message) async {
expect(UTF8.decode(message.buffer.asUint8List()), 'test'); expect(UTF8.decode(message.buffer.asUint8List()), 'test');
completed = true; completed = true;
return new ByteData(5); // 0x0000000000 return new ByteData(5); // 0x0000000000
...@@ -214,7 +214,7 @@ void main() { ...@@ -214,7 +214,7 @@ void main() {
data = await rootBundle.loadStructuredData<bool>('test', (String value) async { expect(value, '\x00\x00\x00\x00\x00'); return false; }); data = await rootBundle.loadStructuredData<bool>('test', (String value) async { expect(value, '\x00\x00\x00\x00\x00'); return false; });
expect(data, isFalse); expect(data, isFalse);
expect(completed, isTrue); expect(completed, isTrue);
PlatformMessages.setMockBinaryMessageHandler('flutter/assets', null); BinaryMessages.setMockMessageHandler('flutter/assets', null);
}); });
test('Service extensions - exit', () async { test('Service extensions - exit', () async {
......
...@@ -11,9 +11,9 @@ import 'package:test/test.dart'; ...@@ -11,9 +11,9 @@ import 'package:test/test.dart';
void main() { void main() {
group('PlatformMessageChannel', () { group('PlatformMessageChannel', () {
const MessageCodec<String> string = const StringCodec(); const MessageCodec<String> string = const StringCodec();
const PlatformMessageChannel<String> channel = const PlatformMessageChannel<String>('ch', string); const BasicMessageChannel<String> channel = const BasicMessageChannel<String>('ch', string);
test('can send string message and get reply', () async { test('can send string message and get reply', () async {
PlatformMessages.setMockBinaryMessageHandler( BinaryMessages.setMockMessageHandler(
'ch', 'ch',
(ByteData message) async => string.encodeMessage(string.decodeMessage(message) + ' world'), (ByteData message) async => string.encodeMessage(string.decodeMessage(message) + ' world'),
); );
...@@ -23,7 +23,7 @@ void main() { ...@@ -23,7 +23,7 @@ void main() {
test('can receive string message and send reply', () async { test('can receive string message and send reply', () async {
channel.setMessageHandler((String message) async => message + ' world'); channel.setMessageHandler((String message) async => message + ' world');
String reply; String reply;
await PlatformMessages.handlePlatformMessage( await BinaryMessages.handlePlatformMessage(
'ch', 'ch',
const StringCodec().encodeMessage('hello'), const StringCodec().encodeMessage('hello'),
(ByteData replyBinary) { (ByteData replyBinary) {
...@@ -37,9 +37,9 @@ void main() { ...@@ -37,9 +37,9 @@ void main() {
group('PlatformMethodChannel', () { group('PlatformMethodChannel', () {
const MessageCodec<dynamic> jsonMessage = const JSONMessageCodec(); const MessageCodec<dynamic> jsonMessage = const JSONMessageCodec();
const MethodCodec jsonMethod = const JSONMethodCodec(); const MethodCodec jsonMethod = const JSONMethodCodec();
const PlatformMethodChannel channel = const PlatformMethodChannel('ch7', jsonMethod); const MethodChannel channel = const MethodChannel('ch7', jsonMethod);
test('can invoke method and get result', () async { test('can invoke method and get result', () async {
PlatformMessages.setMockBinaryMessageHandler( BinaryMessages.setMockMessageHandler(
'ch7', 'ch7',
(ByteData message) async { (ByteData message) async {
final Map<dynamic, dynamic> methodCall = jsonMessage.decodeMessage(message); final Map<dynamic, dynamic> methodCall = jsonMessage.decodeMessage(message);
...@@ -53,7 +53,7 @@ void main() { ...@@ -53,7 +53,7 @@ void main() {
expect(result, equals('hello world')); expect(result, equals('hello world'));
}); });
test('can invoke method and get error', () async { test('can invoke method and get error', () async {
PlatformMessages.setMockBinaryMessageHandler( BinaryMessages.setMockMessageHandler(
'ch7', 'ch7',
(ByteData message) async { (ByteData message) async {
return jsonMessage.encodeMessage(<dynamic>[ return jsonMessage.encodeMessage(<dynamic>[
...@@ -75,7 +75,7 @@ void main() { ...@@ -75,7 +75,7 @@ void main() {
} }
}); });
test('can invoke unimplemented method', () async { test('can invoke unimplemented method', () async {
PlatformMessages.setMockBinaryMessageHandler( BinaryMessages.setMockMessageHandler(
'ch7', 'ch7',
(ByteData message) async => null, (ByteData message) async => null,
); );
...@@ -93,17 +93,17 @@ void main() { ...@@ -93,17 +93,17 @@ void main() {
group('PlatformEventChannel', () { group('PlatformEventChannel', () {
const MessageCodec<dynamic> jsonMessage = const JSONMessageCodec(); const MessageCodec<dynamic> jsonMessage = const JSONMessageCodec();
const MethodCodec jsonMethod = const JSONMethodCodec(); const MethodCodec jsonMethod = const JSONMethodCodec();
const PlatformEventChannel channel = const PlatformEventChannel('ch', jsonMethod); const EventChannel channel = const EventChannel('ch', jsonMethod);
test('can receive event stream', () async { test('can receive event stream', () async {
void emitEvent(dynamic event) { void emitEvent(dynamic event) {
PlatformMessages.handlePlatformMessage( BinaryMessages.handlePlatformMessage(
'ch', 'ch',
event, event,
(ByteData reply) {}, (ByteData reply) {},
); );
} }
bool cancelled = false; bool cancelled = false;
PlatformMessages.setMockBinaryMessageHandler( BinaryMessages.setMockMessageHandler(
'ch', 'ch',
(ByteData message) async { (ByteData message) async {
final Map<dynamic, dynamic> methodCall = jsonMessage.decodeMessage(message); final Map<dynamic, dynamic> methodCall = jsonMessage.decodeMessage(message);
......
...@@ -11,17 +11,17 @@ void main() { ...@@ -11,17 +11,17 @@ void main() {
test('Mock binary message handler control test', () async { test('Mock binary message handler control test', () async {
final List<ByteData> log = <ByteData>[]; final List<ByteData> log = <ByteData>[];
PlatformMessages.setMockBinaryMessageHandler('test1', (ByteData message) async { BinaryMessages.setMockMessageHandler('test1', (ByteData message) async {
log.add(message); log.add(message);
}); });
final ByteData message = new ByteData(2)..setUint16(0, 0xABCD); final ByteData message = new ByteData(2)..setUint16(0, 0xABCD);
await PlatformMessages.sendBinary('test1', message); await BinaryMessages.send('test1', message);
expect(log, equals(<ByteData>[message])); expect(log, equals(<ByteData>[message]));
log.clear(); log.clear();
PlatformMessages.setMockBinaryMessageHandler('test1', null); BinaryMessages.setMockMessageHandler('test1', null);
await PlatformMessages.sendBinary('test1', message); await BinaryMessages.send('test1', message);
expect(log, isEmpty); expect(log, isEmpty);
}); });
} }
...@@ -59,7 +59,7 @@ void main() { ...@@ -59,7 +59,7 @@ void main() {
test('setApplicationSwitcherDescription missing plugin', () async { test('setApplicationSwitcherDescription missing plugin', () async {
final List<ByteData> log = <ByteData>[]; final List<ByteData> log = <ByteData>[];
PlatformMessages.setMockBinaryMessageHandler('flutter/platform', (ByteData message) { BinaryMessages.setMockMessageHandler('flutter/platform', (ByteData message) {
log.add(message); log.add(message);
return null; return null;
}); });
......
...@@ -39,7 +39,7 @@ void main() { ...@@ -39,7 +39,7 @@ void main() {
WidgetsBinding.instance.addObserver(observer); WidgetsBinding.instance.addObserver(observer);
final ByteData message = const JSONMessageCodec().encodeMessage( final ByteData message = const JSONMessageCodec().encodeMessage(
<String, dynamic>{'type': 'memoryPressure'}); <String, dynamic>{'type': 'memoryPressure'});
await PlatformMessages.handlePlatformMessage('flutter/system', message, (_) {}); await BinaryMessages.handlePlatformMessage('flutter/system', message, (_) {});
expect(observer.sawMemoryPressure, true); expect(observer.sawMemoryPressure, true);
WidgetsBinding.instance.removeObserver(observer); WidgetsBinding.instance.removeObserver(observer);
}); });
......
...@@ -7,7 +7,7 @@ import 'package:flutter/widgets.dart'; ...@@ -7,7 +7,7 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
void sendFakeKeyEvent(Map<String, dynamic> data) { void sendFakeKeyEvent(Map<String, dynamic> data) {
PlatformMessages.handlePlatformMessage( BinaryMessages.handlePlatformMessage(
SystemChannels.keyEvent.name, SystemChannels.keyEvent.name,
SystemChannels.keyEvent.codec.encodeMessage(data), SystemChannels.keyEvent.codec.encodeMessage(data),
(_) {}); (_) {});
......
...@@ -41,7 +41,7 @@ class TestTextInput { ...@@ -41,7 +41,7 @@ class TestTextInput {
void updateEditingValue(TextEditingValue value) { void updateEditingValue(TextEditingValue value) {
expect(_client, isNonZero); expect(_client, isNonZero);
PlatformMessages.handlePlatformMessage( BinaryMessages.handlePlatformMessage(
SystemChannels.textInput.name, SystemChannels.textInput.name,
SystemChannels.textInput.codec.encodeMethodCall( SystemChannels.textInput.codec.encodeMethodCall(
new MethodCall( new MethodCall(
......
package {{androidIdentifier}}; package {{androidIdentifier}};
import io.flutter.app.FlutterActivity; import io.flutter.app.FlutterActivity;
import io.flutter.plugin.common.FlutterMethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.FlutterMethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.FlutterMethodChannel.Response; import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
/** /**
...@@ -18,15 +18,15 @@ public class {{pluginClass}} implements MethodCallHandler { ...@@ -18,15 +18,15 @@ public class {{pluginClass}} implements MethodCallHandler {
private {{pluginClass}}(FlutterActivity activity) { private {{pluginClass}}(FlutterActivity activity) {
this.activity = activity; this.activity = activity;
new FlutterMethodChannel(activity.getFlutterView(), "{{projectName}}").setMethodCallHandler(this); new MethodChannel(activity.getFlutterView(), "{{projectName}}").setMethodCallHandler(this);
} }
@Override @Override
public void onMethodCall(MethodCall call, Response response) { public void onMethodCall(MethodCall call, Result result) {
if (call.method.equals("getPlatformVersion")) { if (call.method.equals("getPlatformVersion")) {
response.success("Android " + android.os.Build.VERSION.RELEASE); result.success("Android " + android.os.Build.VERSION.RELEASE);
} else { } else {
response.notImplemented(); result.notImplemented();
} }
} }
} }
...@@ -8,12 +8,14 @@ ...@@ -8,12 +8,14 @@
if (self) { if (self) {
FlutterMethodChannel *channel = [FlutterMethodChannel FlutterMethodChannel *channel = [FlutterMethodChannel
methodChannelWithName:@"{{projectName}}" methodChannelWithName:@"{{projectName}}"
binaryMessenger:controller]; binaryMessenger:controller];
[channel setMethodCallHandler:^(FlutterMethodCall *call, [channel setMethodCallHandler:^(FlutterMethodCall *call,
FlutterResultReceiver result) { FlutterResult result) {
if ([@"getPlatformVersion" isEqualToString:call.method]) { if ([@"getPlatformVersion" isEqualToString:call.method]) {
result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] result([@"iOS " stringByAppendingString:[[UIDevice currentDevice]
systemVersion]]); systemVersion]]);
} else {
result(FlutterMethodNotImplemented);
} }
}]; }];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment