UserCenterViewController.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // UserCenterViewController.m
  3. // XenonSDK
  4. //
  5. // Created by SAGESSE on 2019/5/30.
  6. // Copyright © 2019 SAGESSE. All rights reserved.
  7. //
  8. #import "XenonSDK.h"
  9. #import "RootViewController.h"
  10. #import "UserCenterViewController.h"
  11. #import <objc/message.h>
  12. @interface UserCenterViewController ()
  13. @end
  14. @implementation UserCenterViewController
  15. - (void)sdk_dismissViewController:(id)sender {
  16. [super sdk_dismissViewController:sender];
  17. if (self.callback != nil) {
  18. self.callback();
  19. }
  20. }
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. // Do any additional setup after loading the view.
  24. XSUser* user = XenonSDK.sharedSDK.user;
  25. // -[UIWebView initWithFrame:]
  26. UIView* webView = [[NSClassFromString(fqsd(@"iB0AAM3C0eDe0+fk9wA=")) alloc] initWithFrame:self.containerView.bounds];
  27. if (webView == nil) {
  28. return;
  29. }
  30. webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  31. webView.backgroundColor = UIColor.clearColor;
  32. [webView setValue:self forKey:@"delegate"];
  33. [self.containerView addSubview:webView];
  34. NSURL* url = nil;
  35. if (self.custom == nil) {
  36. NSURLComponents* cmp = [[NSURLComponents alloc] initWithString:[NSString stringWithFormat:@"%@/float/portrait/userinfo.html", XSNetwork.baseURL]];
  37. NSDictionary* json = [XSNetwork bodyWithParameters:@{@"phone":@"",@"uid":user.uid?:@"",@"userName":user.userName?:@""}];
  38. NSString* str = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:json options:0 error:nil] encoding:NSUTF8StringEncoding];
  39. cmp.queryItems = @[[NSURLQueryItem queryItemWithName:@"jsonData" value:str],
  40. [NSURLQueryItem queryItemWithName:@"v" value:@"1"]];
  41. url = cmp.URL;
  42. } else {
  43. url = [NSURL URLWithString:self.custom];
  44. }
  45. // -[UIWebView loadRequest:]
  46. ((void(*)(id,SEL,id))objc_msgSend)(webView, NSSelectorFromString(fqsd(@"rEsAAMHQ0pnAxLe7qr7L0AI=")), [NSURLRequest requestWithURL:url]);
  47. }
  48. - (BOOL)webView:(id)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(NSInteger)navigationType {
  49. // Read the parameter.
  50. NSString* scheme = request.URL.scheme;
  51. if (scheme.length == 0) {
  52. return YES;
  53. }
  54. // Process event
  55. if ([scheme isEqual:@"app"]) {
  56. // Exit game in webview.
  57. if ([request.URL.host isEqual:@"exitAccount"]) {
  58. [XenonSDK.sharedSDK logoutWithComplete:^{
  59. if (XenonSDK.sharedSDK.sdk_logoutCallback != nil) {
  60. XenonSDK.sharedSDK.sdk_logoutCallback(nil);
  61. }
  62. }];
  63. [self sdk_dismissViewController:webView];
  64. return NO;
  65. }
  66. return YES;
  67. }
  68. // Process click back.
  69. if ([scheme isEqual:[NSString stringWithFormat:@"app%@", XenonSDK.sharedSDK.appId]]) {
  70. [self sdk_dismissViewController:webView];
  71. return NO;
  72. }
  73. // Check to see if you start with these characters.
  74. NSArray* rewrites = @[@"http", @"https"];
  75. if ([rewrites containsObject:scheme]) {
  76. return YES;
  77. }
  78. // -[UIApplication openURL:]
  79. ((void(*)(id,SEL,id))objc_msgSend)(UIApplication.sharedApplication, NSSelectorFromString(fqsd(@"p2cAAMrAyrKwq5rIAA==")), request.URL);
  80. return NO;
  81. }
  82. - (void)viewWillAppear:(BOOL)animated {
  83. [super viewWillAppear:animated];
  84. self.otherView.hidden = YES;
  85. }
  86. - (void)viewWillDisappear:(BOOL)animated {
  87. [super viewWillDisappear:animated];
  88. self.otherView.hidden = NO;
  89. }
  90. - (BOOL)prefersUnifiedBackground {
  91. return NO;
  92. }
  93. @end