flutter京东SDK插件
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

48 righe
1.5 KiB

  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