| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- //
- // WentingLicense.m
- // Unity-iPhone
- //
- // Created by 吴博 on 2021/7/23.
- //
- #import "WentingLicense.h"
- #import "WentingLicenseViewController.h"
- #import "UnityAppController.h"
- #define kWentingLicenseAgreeStatus @"WentingLicenseAgreeStatus"
- extern UnityAppController* _UnityAppController;
- extern bool _unityAppReady;
- @interface WentingLicense() <UIApplicationDelegate>
- @property (nonatomic, assign) BOOL agreeStatus;
- @property (nonatomic, assign) BOOL checked;
- @property (nonatomic, strong) WentingLicenseViewController *controller;
- @property (nonatomic, strong) NSDictionary *launchOptions;
- @end
- @implementation WentingLicense
- + (instancetype)sharedInstance {
- static WentingLicense *license = nil;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- license = [[WentingLicense alloc] init];
- });
- return license;
- }
- - (BOOL)CheckAgreeWithLaunchOptions:(NSDictionary*)launchOptions {
- self.agreeStatus = YES;//[[NSUserDefaults standardUserDefaults] boolForKey:kWentingLicenseAgreeStatus];
- if (self.agreeStatus) {
- if (self.checked) {
- [self.controller remove];
- self.controller = nil;
- }
- return NO;
- }
- if (!self.checked) {
- self.checked = YES;
- [UIApplication sharedApplication].delegate = self;
- }
- self.launchOptions = launchOptions;
- if (self.controller == nil) {
- self.controller = [[WentingLicenseViewController alloc] init];
- __weak WentingLicense *weakSelf = self;
- self.controller.cancelAction = ^{
- [weakSelf cancelAgreeLicense];
- };
- self.controller.confirmAction = ^{
- [weakSelf confirmAgreeLicense];
- };
- }
- return YES;
- }
- - (void)cancelAgreeLicense {
- exit(0);
- }
- - (void)confirmAgreeLicense {
- [[NSUserDefaults standardUserDefaults] setBool:true forKey:kWentingLicenseAgreeStatus];
- [UIApplication sharedApplication].delegate = _UnityAppController;
- [_UnityAppController application:[UIApplication sharedApplication] didFinishLaunchingWithOptions:self.launchOptions];
- [_UnityAppController applicationDidBecomeActive:[UIApplication sharedApplication]];
- }
- @end
|