Commit 104e7ba5 authored by Jakob Andersen's avatar Jakob Andersen Committed by GitHub

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

parent 0ee7fabe
...@@ -30,3 +30,7 @@ android { ...@@ -30,3 +30,7 @@ android {
disable 'InvalidPackage' disable 'InvalidPackage'
} }
} }
dependencies {
compile 'com.android.support:support-fragment:25.0.0'
}
...@@ -29,7 +29,7 @@ public class {{pluginClass}} implements MethodCallHandler { ...@@ -29,7 +29,7 @@ public class {{pluginClass}} implements MethodCallHandler {
if (call.method.equals("getPlatformVersion")) { if (call.method.equals("getPlatformVersion")) {
response.success("Android " + android.os.Build.VERSION.RELEASE); response.success("Android " + android.os.Build.VERSION.RELEASE);
} else { } else {
throw new IllegalArgumentException("Unknown method " + call.method); response.notImplemented();
} }
} }
} }
...@@ -7,15 +7,13 @@ ...@@ -7,15 +7,13 @@
self = [super init]; self = [super init];
if (self) { if (self) {
FlutterMethodChannel *channel = [FlutterMethodChannel FlutterMethodChannel *channel = [FlutterMethodChannel
methodChannelNamed:@"{{projectName}}" methodChannelWithName:@"{{projectName}}"
binaryMessenger:flutterView binaryMessenger:flutterView];
codec:[FlutterStandardMethodCodec sharedInstance]];
[channel setMethodCallHandler:^(FlutterMethodCall *call, [channel setMethodCallHandler:^(FlutterMethodCall *call,
FlutterResultReceiver result) { FlutterResultReceiver result) {
if ([@"getPlatformVersion" isEqualToString:call.method]) { if ([@"getPlatformVersion" isEqualToString:call.method]) {
result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] result([@"iOS " stringByAppendingString:[[UIDevice currentDevice]
systemVersion]], systemVersion]]);
nil);
} }
}]; }];
} }
......
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