TtdjPlugin.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #import "TtdjPlugin.h"
  2. #import <DJGameVIPSDK/DJGameVIPSDK.h>
  3. #import "VipViewController.h"
  4. @interface TtdjPlugin() <FlutterPlugin>
  5. @property (nonatomic) UIViewController *viewController;
  6. @end
  7. @implementation TtdjPlugin
  8. + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
  9. UIViewController *viewController = [UIApplication sharedApplication].delegate.window.rootViewController;
  10. FlutterMethodChannel* channel = [FlutterMethodChannel
  11. methodChannelWithName:@"ttdj_plugin"
  12. binaryMessenger:[registrar messenger]];
  13. TtdjPlugin* instance = [[TtdjPlugin alloc] initWithViewController:viewController];
  14. [registrar addMethodCallDelegate:instance channel:channel];
  15. }
  16. - (instancetype)initWithViewController:(UIViewController *)viewController {
  17. self = [super init];
  18. if(self) {
  19. self.viewController = viewController;
  20. }
  21. return self;
  22. }
  23. - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
  24. if ([@"init" isEqualToString:call.method]) {
  25. NSString *userId = call.arguments[@"userId"];
  26. NSString *token = call.arguments[@"token"];
  27. [[DJGameManager defaultManager] configWithAppKey:@"1557281556ibPS1wFSicpPkbem8eW1" secret:@"ecO8lX8W8bQp8vQ9HVhE93t2"];
  28. [[DJGameManager defaultManager] configUserId:userId token:token];
  29. result(@"success");
  30. } else if ([@"gotoVipPage" isEqualToString:call.method]) {
  31. NSBundle *bundle = [NSBundle bundleForClass:[self class]];
  32. NSString *path = [bundle pathForResource:@"DJGameVIPSDK" ofType:@"framework"];
  33. NSBundle *SDKBundle = [NSBundle bundleWithPath:path];
  34. VipViewController *vc = [[VipViewController alloc] initWithNibName:@"DJGameVipViewController" bundle:SDKBundle];
  35. UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
  36. [self.viewController presentViewController:nvc animated:YES completion:nil];
  37. }
  38. }
  39. - (void)close {
  40. }
  41. @end