2023-10-20 13:49:23 +08:00
|
|
|
#import "JcPrinterPlugin.h"
|
2023-10-20 17:45:24 +08:00
|
|
|
#import "JCAPI.h"
|
2023-10-20 13:49:23 +08:00
|
|
|
|
|
|
|
@implementation JcPrinterPlugin
|
|
|
|
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
|
|
|
FlutterMethodChannel* channel = [FlutterMethodChannel
|
|
|
|
methodChannelWithName:@"jc_printer"
|
|
|
|
binaryMessenger:[registrar messenger]];
|
|
|
|
JcPrinterPlugin* instance = [[JcPrinterPlugin 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]]);
|
2023-10-20 17:45:24 +08:00
|
|
|
} else if ([@"connect" isEqualToString:call.method]) {
|
|
|
|
[JCAPI openPrinter:@"123" completion:^(BOOL isSuccess) {
|
|
|
|
if (isSuccess) {
|
|
|
|
result(@"啊叫啊");
|
|
|
|
} else {
|
|
|
|
result(@"版本");
|
|
|
|
}
|
|
|
|
}];
|
2023-10-20 13:49:23 +08:00
|
|
|
} else {
|
|
|
|
result(FlutterMethodNotImplemented);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|