12345678910111213141516171819202122232425262728293031323334353637 |
- #import "CompdfkitFlutterPlugin.h"
- #import "FLNativeView.h"
- #import <ComPDFKit/ComPDFKit.h>
- @implementation CompdfkitFlutterPlugin
- + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
-
- FlutterMethodChannel* channel = [FlutterMethodChannel
- methodChannelWithName:@"com.compdfkit.flutter.plugin"
- binaryMessenger:[registrar messenger]];
- CompdfkitFlutterPlugin* instance = [[CompdfkitFlutterPlugin alloc] init];
- [registrar addMethodCallDelegate:instance channel:channel];
-
- FLNativeViewFactory* factory =
- [[FLNativeViewFactory alloc] initWithMessenger:registrar.messenger];
- [registrar registerViewFactory:factory withId:@"com.compdfkit.flutter.pdfviewer"];
- }
- - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
- if ([@"sdk_version_code" isEqualToString:call.method]) {
- result([CPDFKit sharedInstance].versionString);
- } else if ([@"init_sdk" isEqualToString:call.method]) {
- NSDictionary *initInfo = (NSDictionary *)call.arguments;
- NSString *key = initInfo[@"key"] ?: @"";
- NSString *secret = initInfo[@"secret"] ?: @"";
- [CPDFKit setLicenseKey:key secret:secret];
- } else if ([@"sdk_build_tag" isEqualToString:call.method]) {
- result([@"iOS build tag:" stringByAppendingFormat:@"%ld", [CPDFKit sharedInstance].buildNumber]);
- } else {
- result(FlutterMethodNotImplemented);
- }
- }
- @end
|