Skip to content

Instantly share code, notes, and snippets.

@AbhishekDoshi26
Created July 24, 2021 14:33
Show Gist options
  • Save AbhishekDoshi26/3ca2eb2f3d657b64a5656adede6364f9 to your computer and use it in GitHub Desktop.
Save AbhishekDoshi26/3ca2eb2f3d657b64a5656adede6364f9 to your computer and use it in GitHub Desktop.
#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
@implementation AppDelegate
-
(BOOL) application: (UIApplication * ) application
didFinishLaunchingWithOptions: (NSDictionary * ) launchOptions {
FlutterViewController * controller = (FlutterViewController * ) self.window.rootViewController;
FlutterMethodChannel * nativeChannel = [FlutterMethodChannel
methodChannelWithName: @ "flutter.native/helperChannel"
binaryMessenger: controller
];
__weak typeof (self) weakSelf = self;
[nativeChannel setMethodCallHandler: ^ (FlutterMethodCall * call, FlutterResult result) {
if ([@ "helloFromNativeCode"
isEqualToString: call.method
]) {
NSString * strNative = [weakSelf helloFromNativeCode];
result(strNative);
} else {
result(FlutterMethodNotImplemented);
}
}];
[GeneratedPluginRegistrant registerWithRegistry: self];
return [super application: application didFinishLaunchingWithOptions: launchOptions];
} -
(NSString * ) helloFromNativeCode {
return @ "Hello From Native IOS Code";
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment