flutter京东SDK插件
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JdsdkPlugin.m 1.5 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #import "JdsdkPlugin.h"
  2. #import <jdsdk/JDKeplerSDK.h>
  3. #import "FlutterKeplerHandler.h"
  4. @interface JdsdkPlugin()
  5. @property(nonatomic,strong) FlutterKeplerHandler *keplerHandler;
  6. @end
  7. @implementation JdsdkPlugin
  8. + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
  9. NSLog(@"registerWithRegistrar");
  10. FlutterMethodChannel* channel = [FlutterMethodChannel
  11. methodChannelWithName:@"jdsdk"
  12. binaryMessenger:[registrar messenger]];
  13. // JdsdkPlugin* instance = [[JdsdkPlugin alloc] init];
  14. //将 JdsdkPlugin 的无参 init 函数调整为 initWithRegistrar
  15. JdsdkPlugin* instance = [[JdsdkPlugin alloc] initWithRegistrar:registrar];
  16. [registrar addMethodCallDelegate:instance channel:channel];
  17. }
  18. - (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar {
  19. NSLog(@"initWithRegistrar");
  20. self = [super init];
  21. if (self) {
  22. self.keplerHandler = [[FlutterKeplerHandler alloc]init];
  23. }
  24. return self;
  25. }
  26. - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
  27. if ([@"getPlatformVersion" isEqualToString:call.method]) {
  28. result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
  29. } else if ([@"init" isEqualToString:call.method]) {
  30. NSLog(@"init flutter");
  31. [_keplerHandler initKepler:call result:result];
  32. }else if ([@"openUrl" isEqualToString:call.method]) {
  33. [_keplerHandler keplerPageWithURL:call result:result];
  34. }else {
  35. result(FlutterMethodNotImplemented);
  36. }
  37. }
  38. @end