#import "AppDelegate.h"
#import "GeneratedPluginRegistrant.h"


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [GeneratedPluginRegistrant registerWithRegistry:self];
  // Override point for customization after application launch.

FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController;
__block NSDictionary *remoteNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

    FlutterMethodChannel* bridgeAppChannel = [FlutterMethodChannel methodChannelWithName:@"bridge" binaryMessenger:(NSObject<FlutterBinaryMessenger> *)controller];
    [bridgeAppChannel setMethodCallHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult  _Nonnull result) {
        NSString * method = call.method;
        if ([method isEqual:@"action"]) {
            if (remoteNotification != NULL) {
                result(remoteNotification[@"custom"]);
                remoteNotification = nil;
            }
            result(@"");
        }
        if ([method isEqual:@"toAppStore"]) {
            NSString *appURL = @"https://itunes.apple.com/cn/app/1575124838?action=write-review";
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:appURL]];
            result(@"");
        }
        //result(FlutterMethodNotImplemented);
    }];

  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@end