#import "GuruApplifecycleFlutterPlugin.h"
#import "AppStateNotifier.h"

@implementation GuruApplifecycleFlutterPlugin {
  AppStateNotifier *_appStateNotifier;
}
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
  FlutterMethodChannel* channel = [FlutterMethodChannel
      methodChannelWithName:@"guru_applifecycle_flutter"
            binaryMessenger:[registrar messenger]];
  GuruApplifecycleFlutterPlugin* instance = [[GuruApplifecycleFlutterPlugin alloc] initWithBinaryMessenger:registrar.messenger];
  [registrar addMethodCallDelegate:instance channel:channel];
}

- (instancetype)init {
  self = [super init];
  return self;
}

- (instancetype)initWithBinaryMessenger:
    (id<FlutterBinaryMessenger>)binaryMessenger {
  self = [self init];
  if (self) {
    _appStateNotifier =
        [[AppStateNotifier alloc] initWithBinaryMessenger:binaryMessenger];
  }

  return self;
}

- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
  if ([@"getPlatformVersion" isEqualToString:call.method]) {
    result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
  } else {
    result(FlutterMethodNotImplemented);
  }
}

@end
