#import "CoreLocationFluttifyPlugin.h" #import "CLLocationCoordinate2DHandler.h" #import "CLLocationHandler.h" #import "CLFloorHandler.h" #import "CLLocationManagerHandler.h" #import "CLHeadingHandler.h" #import "FluttifyMessageCodec.h" // Container for Dart side random access objects extern NSMutableDictionary *HEAP; // whether enable log or not extern BOOL enableLog; @implementation CoreLocationFluttifyPlugin { NSObject *_registrar; } + (void)registerWithRegistrar:(NSObject *)registrar { NSString* _channelName = @"com.fluttify/core_location_method"; FlutterMethodChannel *channel = [FlutterMethodChannel methodChannelWithName:_channelName binaryMessenger:[registrar messenger] codec:[FlutterStandardMethodCodec codecWithReaderWriter:[[FluttifyReaderWriter alloc] init]]]; CoreLocationFluttifyPlugin *instance = [[CoreLocationFluttifyPlugin alloc] initWithRegistrar:registrar]; [registrar addMethodCallDelegate:instance channel:channel]; } - (instancetype)initWithRegistrar:(NSObject *)registrar { self = [super init]; if (self) { _registrar = registrar; } return self; } - (void)handleMethodCall:(FlutterMethodCall *)methodCall result:(FlutterResult)methodResult { id rawArgs = [methodCall arguments]; if ([methodCall.method hasPrefix:@"CLLocationCoordinate2D"]) { CLLocationCoordinate2DHandler(methodCall.method, rawArgs, methodResult); } else if ([methodCall.method hasPrefix:@"CLLocation"]) { CLLocationHandler(methodCall.method, rawArgs, methodResult); } else if ([methodCall.method hasPrefix:@"CLFloor"]) { CLFloorHandler(methodCall.method, rawArgs, methodResult); } else if ([methodCall.method hasPrefix:@"CLLocationManager"]) { CLLocationManagerHandler(methodCall.method, rawArgs, methodResult); } else if ([methodCall.method hasPrefix:@"CLHeadingHandler"]) { CLHeadingHandler(methodCall.method, rawArgs, methodResult); } else { methodResult(FlutterMethodNotImplemented); } } @end