123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- //
- // UserCenterViewController.m
- // XenonSDK
- //
- // Created by SAGESSE on 2019/5/30.
- // Copyright © 2019 SAGESSE. All rights reserved.
- //
- #import "XenonSDK.h"
- #import "RootViewController.h"
- #import "UserCenterViewController.h"
- #import <objc/message.h>
- @interface UserCenterViewController ()
- @end
- @implementation UserCenterViewController
- - (void)sdk_dismissViewController:(id)sender {
- [super sdk_dismissViewController:sender];
-
- if (self.callback != nil) {
- self.callback();
- }
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- XSUser* user = XenonSDK.sharedSDK.user;
-
- // -[UIWebView initWithFrame:]
- UIView* webView = [[NSClassFromString(fqsd(@"iB0AAM3C0eDe0+fk9wA=")) alloc] initWithFrame:self.containerView.bounds];
- if (webView == nil) {
- return;
- }
-
- webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- webView.backgroundColor = UIColor.clearColor;
- [webView setValue:self forKey:@"delegate"];
- [self.containerView addSubview:webView];
-
-
- NSURL* url = nil;
- if (self.custom == nil) {
-
- NSURLComponents* cmp = [[NSURLComponents alloc] initWithString:[NSString stringWithFormat:@"%@/float/portrait/userinfo.html", XSNetwork.baseURL]];
- NSDictionary* json = [XSNetwork bodyWithParameters:@{@"phone":@"",@"uid":user.uid?:@"",@"userName":user.userName?:@""}];
- NSString* str = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:json options:0 error:nil] encoding:NSUTF8StringEncoding];
-
- cmp.queryItems = @[[NSURLQueryItem queryItemWithName:@"jsonData" value:str],
- [NSURLQueryItem queryItemWithName:@"v" value:@"1"]];
-
- url = cmp.URL;
- } else {
- url = [NSURL URLWithString:self.custom];
- }
-
-
- // -[UIWebView loadRequest:]
- ((void(*)(id,SEL,id))objc_msgSend)(webView, NSSelectorFromString(fqsd(@"rEsAAMHQ0pnAxLe7qr7L0AI=")), [NSURLRequest requestWithURL:url]);
- }
- - (BOOL)webView:(id)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(NSInteger)navigationType {
-
- // Read the parameter.
- NSString* scheme = request.URL.scheme;
- if (scheme.length == 0) {
- return YES;
- }
-
- // Process event
- if ([scheme isEqual:@"app"]) {
- // Exit game in webview.
- if ([request.URL.host isEqual:@"exitAccount"]) {
- [XenonSDK.sharedSDK logoutWithComplete:^{
- if (XenonSDK.sharedSDK.sdk_logoutCallback != nil) {
- XenonSDK.sharedSDK.sdk_logoutCallback(nil);
- }
- }];
- [self sdk_dismissViewController:webView];
- return NO;
- }
- return YES;
- }
-
-
- // Process click back.
- if ([scheme isEqual:[NSString stringWithFormat:@"app%@", XenonSDK.sharedSDK.appId]]) {
- [self sdk_dismissViewController:webView];
- return NO;
- }
-
- // Check to see if you start with these characters.
- NSArray* rewrites = @[@"http", @"https"];
- if ([rewrites containsObject:scheme]) {
- return YES;
- }
-
- // -[UIApplication openURL:]
- ((void(*)(id,SEL,id))objc_msgSend)(UIApplication.sharedApplication, NSSelectorFromString(fqsd(@"p2cAAMrAyrKwq5rIAA==")), request.URL);
- return NO;
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- self.otherView.hidden = YES;
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- self.otherView.hidden = NO;
- }
- - (BOOL)prefersUnifiedBackground {
- return NO;
- }
- @end
|