133 lines
4.5 KiB
Objective-C
133 lines
4.5 KiB
Objective-C
//
|
|
// CustomAppController.m
|
|
// UnityFramework
|
|
//
|
|
// Created by Mac on 2024/1/17.
|
|
//
|
|
//#import "CustomAppController.h"
|
|
//#import "H5View.h"
|
|
//
|
|
//#import <CoreTelephony/CTTelephonyNetworkInfo.h>
|
|
//#import <CoreTelephony/CTCarrier.h>
|
|
//@interface CustomAppController ()
|
|
//
|
|
//@property(nonatomic, strong) WKWebView *webView;
|
|
//
|
|
//@end
|
|
|
|
//@implementation CustomAppController {
|
|
// UIButton *btn;
|
|
// H5View *hview;
|
|
//}
|
|
//- (void)startUnity:(UIApplication *)application {
|
|
// [super startUnity:application];
|
|
//
|
|
// UIView* unityView = UnityGetGLView();
|
|
//
|
|
// UIViewController *vc = [UIViewController new];
|
|
// vc.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
// //[vc.view setFrame:self.window.bounds];
|
|
// //[vc.view setBackgroundColor:[UIColor orangeColor]];
|
|
// [self.window setRootViewController:vc];
|
|
//
|
|
// [vc.view addSubview:unityView];
|
|
//
|
|
// hview = [H5View shared];
|
|
// [vc.view addSubview:hview];
|
|
//
|
|
// [hview setFrame:self.window.bounds];
|
|
// [hview initView];
|
|
//
|
|
// CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init];
|
|
//
|
|
// if (@available(iOS 12.0, *)) {
|
|
// NSDictionary *ctDict = networkInfo.serviceSubscriberCellularProviders;
|
|
// if ([ctDict allKeys].count > 1) {
|
|
// NSArray *keys = [ctDict allKeys];
|
|
// CTCarrier *carrier1 = [ctDict objectForKey:[keys firstObject]];
|
|
// CTCarrier *carrier2 = [ctDict objectForKey:[keys lastObject]];
|
|
// if (carrier1.mobileCountryCode.length && carrier2.mobileCountryCode.length) {
|
|
// UnitySendMessage("NetworkManager", "diaoyongtest", "TRUE");
|
|
//
|
|
// }else if (!carrier1.mobileCountryCode.length && !carrier2.mobileCountryCode.length) {
|
|
// UnitySendMessage("NetworkManager", "diaoyongtest", "FALSE");
|
|
//
|
|
// }else {
|
|
// UnitySendMessage("NetworkManager", "diaoyongtest", "TRUE");
|
|
// }
|
|
// }else if ([ctDict allKeys].count == 1) {
|
|
// NSArray *keys = [ctDict allKeys];
|
|
// CTCarrier *carrier1 = [ctDict objectForKey:[keys firstObject]];
|
|
// if (carrier1.mobileCountryCode.length) {
|
|
// UnitySendMessage("NetworkManager", "diaoyongtest", "TRUE");
|
|
// }else {
|
|
// UnitySendMessage("NetworkManager", "diaoyongtest", "FALSE");
|
|
// }
|
|
// }else {
|
|
// UnitySendMessage("NetworkManager", "diaoyongtest", "FALSE");
|
|
// }
|
|
// }
|
|
// NSArray *preferredLanguages = [NSLocale preferredLanguages];
|
|
// NSString *firstLanguage = preferredLanguages.firstObject;
|
|
//
|
|
// if ([firstLanguage hasPrefix:@"pt"]) {
|
|
// // 设备设置为葡萄牙语
|
|
// UnitySendMessage("UIManager", "setLangguage", "pt");
|
|
// } else {
|
|
// // 设备未设置为葡萄牙语
|
|
// UnitySendMessage("UIManager", "setLangguage", "en");
|
|
// }
|
|
//
|
|
|
|
// customView = [CustomView shared];
|
|
// [vc.view addSubview:customView];
|
|
|
|
// [customView setFrame:self.window.bounds];
|
|
// [customView initView];
|
|
|
|
// [customView addSubview:unityView];
|
|
//unityView.userInteractionEnabled = false;
|
|
|
|
|
|
|
|
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(:) name:@"OpenWebview" object:nil];
|
|
|
|
// UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
|
|
// [button setTitle:@"show Webview" forState:UIControlStateNormal];
|
|
// [button sizeToFit];
|
|
// [button addTarget:self action:@selector(showWebview:)
|
|
// forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
// // Set a new (x,y) point for the button's center
|
|
// button.center = CGPointMake(100, 80);
|
|
|
|
// [customView addSubview:button];
|
|
|
|
// UIButton *button2 = [UIButton buttonWithType:UIButtonTypeSystem];
|
|
// [button2 setTitle:@"hide Webview" forState:UIControlStateNormal];
|
|
// [button2 sizeToFit];
|
|
// [button2 addTarget:self action:@selector(hideWebview:)
|
|
// forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
// // Set a new (x,y) point for the button's center
|
|
// button2.center = CGPointMake(100, 120);
|
|
|
|
// [customView addSubview:button2];
|
|
//}
|
|
|
|
//- (void)notificationFired:(NSNotification *)notification {
|
|
// customView showWebview:<#(nonnull NSString *)#>
|
|
//}
|
|
|
|
// -(void)showWebview:(UIButton *)button{
|
|
// [[CustomView shared] showWebview:@"https://baidu.com"];
|
|
// }
|
|
|
|
// -(void)hideWebview:(UIButton *)button{
|
|
// [customView hideWebview];
|
|
// }
|
|
|
|
|
|
//@end
|
|
|