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.
 
 
 
 
 

46 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%@",error);
  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. NSLog(@"JDUrl%@",url);
  25. if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:[NSString stringWithFormat:@"openapp.jdmobile://"]]]) {
  26. //判断是否安装京东app
  27. // 判断是否安装京东app
  28. [[KeplerApiManager sharedKPService] openKeplerPageWithURL:url userInfo:@{@"mopenbp5" : @""} successCallback:^{
  29. NSLog (@"success");
  30. result(@"{status:1}");
  31. } failedCallback:^(NSInteger code, NSString * _Nonnull url) {
  32. NSLog (@"fail");
  33. result(@"{status:0}");
  34. }];
  35. }else{
  36. result(@"{status:0}");
  37. }
  38. }
  39. @end