flutter京东SDK插件
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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