flutter京东SDK插件
 
 
 
 
 

44 lines
1.7 KiB

  1. #import "FlutterKeplerHandler.h"
  2. #import <jdsdk/JDKeplerSDK.h>
  3. @implementation FlutterKeplerHandler
  4. //初始化开普勒
  5. - (void)initKepler:(FlutterMethodCall *)call result:(FlutterResult)result {
  6. NSString *appKey = call.arguments[@"appKey"];
  7. NSString *appSecret = call.arguments[@"appSecret"];
  8. NSLog (@"appKey is :%@", appKey);
  9. NSLog (@"appSecret is :%@", appSecret);
  10. [[KeplerApiManager sharedKPService]asyncInitSdk:appKey secretKey:appSecret sucessCallback:^(){
  11. NSLog (@"success");
  12. result(@"{status:1}");
  13. }failedCallback:^(NSError *error){
  14. NSLog (@"fail");
  15. result(@"{status:0}");
  16. }];
  17. }
  18. - (void)keplerPageWithURL:(FlutterMethodCall *)call result:(FlutterResult)result {
  19. NSString *url = call.arguments[@"url"];
  20. // NSInteger jumpType = [call.arguments[@"jumpType"] integerValue];
  21. NSInteger jumpType = [[NSNumber numberWithInt:1] integerValue];
  22. // NSDictionary *userInfo = [FlutterKeplerTools nullToNil:call.arguments[@"userInfo"]];
  23. UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
  24. if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:[NSString stringWithFormat:@"openapp.jdmobile://"]]]) {//判断是否安装京东app
  25. [ [KeplerApiManager sharedKPService]openKeplerPageWithURL:url userInfo:nil successCallback:^{
  26. NSLog (@"success");
  27. result(@"{status:1}");
  28. } failedCallback:^(NSInteger code, NSString * _Nonnull url) {
  29. NSLog (@"fail");
  30. result(@"{status:0}");
  31. }];
  32. }else{
  33. result(@"{status:0}");
  34. }
  35. }
  36. @end