Update plugin template to new channel API. (#9105)

This commit is contained in:
Jakob Andersen
2017-03-30 21:25:31 +02:00
committed by GitHub
parent 0ee7fabe9a
commit 104e7ba576
3 changed files with 8 additions and 6 deletions

View File

@@ -30,3 +30,7 @@ android {
disable 'InvalidPackage'
}
}
dependencies {
compile 'com.android.support:support-fragment:25.0.0'
}

View File

@@ -29,7 +29,7 @@ public class {{pluginClass}} implements MethodCallHandler {
if (call.method.equals("getPlatformVersion")) {
response.success("Android " + android.os.Build.VERSION.RELEASE);
} else {
throw new IllegalArgumentException("Unknown method " + call.method);
response.notImplemented();
}
}
}

View File

@@ -7,15 +7,13 @@
self = [super init];
if (self) {
FlutterMethodChannel *channel = [FlutterMethodChannel
methodChannelNamed:@"{{projectName}}"
binaryMessenger:flutterView
codec:[FlutterStandardMethodCodec sharedInstance]];
methodChannelWithName:@"{{projectName}}"
binaryMessenger:flutterView];
[channel setMethodCallHandler:^(FlutterMethodCall *call,
FlutterResultReceiver result) {
if ([@"getPlatformVersion" isEqualToString:call.method]) {
result([@"iOS " stringByAppendingString:[[UIDevice currentDevice]
systemVersion]],
nil);
systemVersion]]);
}
}];
}