Skip to content

Instantly share code, notes, and snippets.

@ponnamkarthik
Last active April 22, 2018 10:00
Show Gist options
  • Save ponnamkarthik/a54a2fa14ccc6f2a6a9f3b7782b1c370 to your computer and use it in GitHub Desktop.
Save ponnamkarthik/a54a2fa14ccc6f2a6a9f3b7782b1c370 to your computer and use it in GitHub Desktop.
FlutterNativeLogPlugin.m
#import "FlutterNativeLogPlugin.h"
@implementation FlutterNativeLogPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
FlutterMethodChannel* channel = [FlutterMethodChannel
methodChannelWithName:@"flutter_native_log"
binaryMessenger:[registrar messenger]];
FlutterNativeLogPlugin* instance = [[FlutterNativeLogPlugin alloc] init];
[registrar addMethodCallDelegate:instance channel:channel];
}
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
if ([@"getPlatformVersion" isEqualToString:call.method]) {
result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
} else if([@"printLog" isEqualToStrin:call.method]) {
NSString *msg = call.arguments[@"msg"];
NSString *tag = call.arguments[@"tag"];
NSLog(@"%@: %@", tag, msg);
result(@"Logged Successfully!")
}else {
result(FlutterMethodNotImplemented);
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment