2025-08-08 10:49:36 +08:00
|
|
|
|
//
|
|
|
|
|
|
// AppDelegate.m
|
|
|
|
|
|
// QXLive
|
|
|
|
|
|
//
|
|
|
|
|
|
// Created by 启星 on 2025/4/24.
|
|
|
|
|
|
//
|
2025-10-20 09:43:10 +08:00
|
|
|
|
/**
|
|
|
|
|
|
APP准备启动
|
|
|
|
|
|
*
|
|
|
|
|
|
* _oo0oo_
|
|
|
|
|
|
* o8888888o
|
|
|
|
|
|
* 88" . "88
|
|
|
|
|
|
* (| -_- |)
|
|
|
|
|
|
* 0\ = /0
|
|
|
|
|
|
* ___/`---'\___
|
|
|
|
|
|
* .' \\| |// '.
|
|
|
|
|
|
* / \\||| : |||// \
|
|
|
|
|
|
* / _||||| -卍-|||||- \
|
|
|
|
|
|
* | | \\\ - /// | |
|
|
|
|
|
|
* | \_| ''\---/'' |_/ |
|
|
|
|
|
|
* \ .-\__ '-' ___/-. /
|
|
|
|
|
|
* ___'. .' /--.--\ `. .'___
|
|
|
|
|
|
* ."" '< `.___\_<|>_/___.' >' "".
|
|
|
|
|
|
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
|
|
|
|
|
|
* \ \ `_. \_ __\ /__ _/ .-` / /
|
|
|
|
|
|
*=====`-.____`.___ \_____/___.-`___.-'=====
|
|
|
|
|
|
* `=---='
|
|
|
|
|
|
*
|
|
|
|
|
|
* 佛祖保佑 永无BUG
|
|
|
|
|
|
* 佛曰:
|
|
|
|
|
|
* 写字楼里写字间,写字间里程序员;
|
|
|
|
|
|
* 程序人员写程序,又拿程序换酒钱。
|
|
|
|
|
|
* 酒醒只在网上坐,酒醉还来网下眠;
|
|
|
|
|
|
* 酒醉酒醒日复日,网上网下年复年。
|
|
|
|
|
|
* 但愿老死电脑间,不愿鞠躬老板前;
|
|
|
|
|
|
* 奔驰宝马贵者趣,公交自行程序员。
|
|
|
|
|
|
* 别人笑我忒疯癫,我笑自己命太贱;
|
|
|
|
|
|
* 不见满街漂亮妹,哪个归得程序员?
|
|
|
|
|
|
*/
|
2025-08-08 10:49:36 +08:00
|
|
|
|
|
|
|
|
|
|
#import "AppDelegate.h"
|
|
|
|
|
|
#import "AppDelegate+Login.h"
|
|
|
|
|
|
#import "QXFillUserInfoViewController.h"
|
|
|
|
|
|
#import "AvoidCrash.h"
|
|
|
|
|
|
#import <WXApi.h>
|
|
|
|
|
|
#import <Bugly/Bugly.h>
|
|
|
|
|
|
#import <AlipaySDK/AlipaySDK.h>
|
|
|
|
|
|
#import <TIMPush/TIMPushManager.h>
|
|
|
|
|
|
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
|
2025-08-14 09:40:25 +08:00
|
|
|
|
#import "QXAppStartViewController.h"
|
2025-10-20 09:43:10 +08:00
|
|
|
|
#import "QXGiftPlayerManager.h"
|
2025-10-25 19:38:29 +08:00
|
|
|
|
#import "QXGiftDisplayManager.h"
|
2025-10-20 09:43:10 +08:00
|
|
|
|
#import "IQKeyboardManager.h"
|
|
|
|
|
|
#import "QXChirldViewController.h"
|
|
|
|
|
|
#import "QXMineNetwork.h"
|
2025-10-28 09:18:28 +08:00
|
|
|
|
#import "QXRoomNavigationController.h"
|
2025-08-08 10:49:36 +08:00
|
|
|
|
#if DEBUG
|
|
|
|
|
|
#import <LLDebugTool.h>
|
|
|
|
|
|
#endif
|
|
|
|
|
|
@interface AppDelegate ()<WXApiDelegate>
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation AppDelegate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
2025-10-20 09:43:10 +08:00
|
|
|
|
NSArray *array = [UIFont familyNames];
|
|
|
|
|
|
for (NSString * familyname in array) {
|
|
|
|
|
|
NSLog(@"Family:%@" ,familyname);
|
|
|
|
|
|
// NSArray *fontnames = [UIFont fontNamesForFamilyName:familyname];
|
|
|
|
|
|
// for (NSString *name in fontnames) {
|
|
|
|
|
|
// NSLog(@"Font Name:%@" ,name);
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-08 10:49:36 +08:00
|
|
|
|
// Override point for customization after application launch.
|
|
|
|
|
|
[QXConfig defaultConfig];
|
|
|
|
|
|
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
|
|
|
|
self.window.backgroundColor = [UIColor whiteColor];
|
2025-08-14 09:40:25 +08:00
|
|
|
|
QXAppStartViewController *startVC = [[QXAppStartViewController alloc] init];
|
|
|
|
|
|
self.window.rootViewController = startVC;
|
2025-10-25 20:31:02 +08:00
|
|
|
|
[Bugly startWithAppId:@"38d154fc5f"];
|
2025-08-08 10:49:36 +08:00
|
|
|
|
SDImageWebPCoder *webPCoder = [SDImageWebPCoder sharedCoder];
|
2025-10-20 09:43:10 +08:00
|
|
|
|
[IQKeyboardManager sharedManager].enable = NO;
|
2025-08-08 10:49:36 +08:00
|
|
|
|
[[SDImageCodersManager sharedManager] addCoder:webPCoder];
|
|
|
|
|
|
[self configThirdPartLogin];
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
|
[[LLDebugTool sharedTool] startWorking];
|
|
|
|
|
|
#endif
|
|
|
|
|
|
[self crash];
|
|
|
|
|
|
[self.window makeKeyAndVisible];
|
|
|
|
|
|
return YES;
|
|
|
|
|
|
}
|
|
|
|
|
|
-(void)crash{
|
|
|
|
|
|
NSArray *noneSelClassStrings = @[
|
|
|
|
|
|
@"NSNull",
|
|
|
|
|
|
@"NSNumber",
|
|
|
|
|
|
@"NSString",
|
|
|
|
|
|
@"NSDictionary",
|
|
|
|
|
|
@"NSArray"
|
|
|
|
|
|
];
|
|
|
|
|
|
[AvoidCrash setupNoneSelClassStringsArr:noneSelClassStrings];
|
|
|
|
|
|
[AvoidCrash becomeEffective];
|
|
|
|
|
|
}
|
|
|
|
|
|
-(void)changeRootViewControllerIsTabbar{
|
2025-10-20 09:43:10 +08:00
|
|
|
|
NSString *localPassword = [[NSUserDefaults standardUserDefaults] objectForKey:kChirldLocalPassword];
|
2025-08-14 09:40:25 +08:00
|
|
|
|
if ([QXGlobal shareGlobal].isLogin && [[QXGlobal shareGlobal].loginModel.sex isEqualToString:@"0"]) {
|
|
|
|
|
|
QXFillUserInfoViewController *vc = [[QXFillUserInfoViewController alloc] init];
|
|
|
|
|
|
self.window.rootViewController = vc;
|
2025-10-20 09:43:10 +08:00
|
|
|
|
}else if([localPassword isExist]){
|
|
|
|
|
|
QXChirldViewController*vc = [[QXChirldViewController alloc] init];
|
|
|
|
|
|
vc.isRoot = YES;
|
|
|
|
|
|
QXBaseNavigationController *na = [[QXBaseNavigationController alloc] initWithRootViewController:vc];
|
|
|
|
|
|
self.window.rootViewController = na;
|
2025-08-14 09:40:25 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
self.tabbarVC = [[QXTabbarController alloc] init];
|
2025-10-28 09:18:28 +08:00
|
|
|
|
QXRoomNavigationController *na = [[QXRoomNavigationController alloc] initWithRootViewController:self.tabbarVC];
|
2025-08-14 09:40:25 +08:00
|
|
|
|
na.navigationBarHidden = YES;
|
|
|
|
|
|
self.window.rootViewController = na;
|
|
|
|
|
|
}
|
2025-08-08 10:49:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler{
|
|
|
|
|
|
BOOL result =[WXApi handleOpenUniversalLink:userActivity delegate:self];
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: 9.0以后使用新API接口
|
|
|
|
|
|
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options{
|
|
|
|
|
|
if ([url.host isEqualToString:@"safepay"]) {
|
|
|
|
|
|
// 支付跳转支付宝钱包进行支付,处理支付结果
|
|
|
|
|
|
[[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
|
|
|
|
|
|
NSLog(@"result = %@",resultDic);
|
|
|
|
|
|
NSString *result = [NSString stringWithFormat:@"%@",resultDic[@"memo"]];
|
|
|
|
|
|
NSString *resultStatus = [NSString stringWithFormat:@"%@",resultDic[@"resultStatus"]];
|
|
|
|
|
|
|
|
|
|
|
|
if (resultStatus.intValue == 9000) {
|
|
|
|
|
|
showToast(@"支付成功");
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:noticeAlipayResult object:nil];
|
2025-10-20 09:43:10 +08:00
|
|
|
|
[QXMineNetwork getMineInfoSuccessBlock:^(QXUserModel * _Nonnull userModel) {
|
|
|
|
|
|
|
|
|
|
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
|
|
|
|
|
|
|
|
}];
|
2025-08-08 10:49:36 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
showToast(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
}];
|
|
|
|
|
|
// // 授权跳转支付宝钱包进行支付,处理支付结果
|
|
|
|
|
|
// [[AlipaySDK defaultService] processAuthResult:url standbyCallback:^(NSDictionary *resultDic) {
|
|
|
|
|
|
// NSLog(@"result = %@",resultDic);
|
|
|
|
|
|
// // 解析 auth code
|
|
|
|
|
|
// NSString *result = resultDic[@"result"];
|
|
|
|
|
|
// NSString *authCode = nil;
|
|
|
|
|
|
// if (result.length>0) {
|
|
|
|
|
|
// NSArray *resultArr = [result componentsSeparatedByString:@"&"];
|
|
|
|
|
|
// for (NSString *subResult in resultArr) {
|
|
|
|
|
|
// if (subResult.length > 10 && [subResult hasPrefix:@"auth_code="]) {
|
|
|
|
|
|
// authCode = [subResult substringFromIndex:10];
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// NSLog(@"授权结果 authCode = %@", authCode?:@"");
|
|
|
|
|
|
// [[NSNotificationCenter defaultCenter]postNotificationName:@"RELOADBLANCE" object:nil];
|
|
|
|
|
|
// }];
|
|
|
|
|
|
[[AlipaySDK defaultService] processAuth_V2Result:url standbyCallback:^(NSDictionary *resultDic) {
|
|
|
|
|
|
QXLOG(@"auth = %@",resultDic);
|
|
|
|
|
|
NSString *result = resultDic[@"result"];
|
|
|
|
|
|
NSString *authCode = nil;
|
|
|
|
|
|
if (result.length>0) {
|
|
|
|
|
|
NSArray *resultArr = [result componentsSeparatedByString:@"&"];
|
|
|
|
|
|
for (NSString *subResult in resultArr) {
|
|
|
|
|
|
if (subResult.length > 10 && [subResult hasPrefix:@"auth_code="]) {
|
|
|
|
|
|
authCode = [subResult substringFromIndex:10];
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
NSLog(@"授权结果 authCode = %@", authCode?:@"");
|
|
|
|
|
|
}];
|
|
|
|
|
|
}else if ([url.host isEqualToString:@"pay"]){
|
|
|
|
|
|
return [WXApi handleOpenURL:url delegate:self];
|
|
|
|
|
|
|
|
|
|
|
|
}else if ([url.host isEqualToString:@"oauth"]){
|
|
|
|
|
|
return [WXApi handleOpenURL:url delegate:self];
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return [WXApi handleOpenURL:url delegate:self];
|
|
|
|
|
|
}
|
|
|
|
|
|
return YES;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
|
|
|
|
|
|
//{
|
|
|
|
|
|
// if ([url.host isEqualToString:@"safepay"]) {
|
|
|
|
|
|
// // 支付跳转支付宝钱包进行支付,处理支付结果
|
|
|
|
|
|
// [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
|
|
|
|
|
|
// NSLog(@"result = %@",resultDic);
|
|
|
|
|
|
// }];
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 授权跳转支付宝钱包进行支付,处理支付结果
|
|
|
|
|
|
// [[AlipaySDK defaultService] processAuth_V2Result:url standbyCallback:^(NSDictionary *resultDic) {
|
|
|
|
|
|
// NSLog(@"result = %@",resultDic);
|
|
|
|
|
|
// // 解析 auth code
|
|
|
|
|
|
// NSString *result = resultDic[@"result"];
|
|
|
|
|
|
// NSString *authCode = nil;
|
|
|
|
|
|
// if (result.length>0) {
|
|
|
|
|
|
// NSArray *resultArr = [result componentsSeparatedByString:@"&"];
|
|
|
|
|
|
// for (NSString *subResult in resultArr) {
|
|
|
|
|
|
// if (subResult.length > 10 && [subResult hasPrefix:@"auth_code="]) {
|
|
|
|
|
|
// authCode = [subResult substringFromIndex:10];
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// NSLog(@"授权结果 authCode = %@", authCode?:@"");
|
|
|
|
|
|
// }];
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return YES;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(void)onResp:(BaseResp *)resp
|
|
|
|
|
|
{
|
|
|
|
|
|
if ([resp isKindOfClass:[PayResp class]])
|
|
|
|
|
|
{
|
|
|
|
|
|
PayResp *response = (PayResp *)resp;
|
|
|
|
|
|
switch (response.errCode)
|
|
|
|
|
|
{
|
|
|
|
|
|
case WXSuccess:
|
|
|
|
|
|
//服务器端查询支付通知或查询API返回的结果再提示成功
|
|
|
|
|
|
NSLog(@"支付成功");
|
|
|
|
|
|
showToast(QXText(@"支付成功"));
|
2025-10-20 09:43:10 +08:00
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:noticeAlipayResult object:nil];
|
|
|
|
|
|
[QXMineNetwork getMineInfoSuccessBlock:^(QXUserModel * _Nonnull userModel) {
|
|
|
|
|
|
|
|
|
|
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
|
|
|
|
|
|
|
|
}];
|
2025-08-08 10:49:36 +08:00
|
|
|
|
break;
|
|
|
|
|
|
case WXErrCodeUserCancel:
|
|
|
|
|
|
//服务器端查询支付通知或查询API返回的结果再提示成功
|
|
|
|
|
|
//交易取消
|
|
|
|
|
|
showToast(QXText(@"取消支付"));
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
NSLog(@"支付失败, retcode=%d",resp.errCode);
|
|
|
|
|
|
showToast(QXText(@"支付失败"));
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if([resp isKindOfClass:[SendAuthResp class]]){
|
|
|
|
|
|
SendAuthResp *response = (SendAuthResp *)resp;
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:noticeWeChatLogin object:response];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-20 09:43:10 +08:00
|
|
|
|
-(void)applicationDidEnterBackground:(UIApplication *)application{
|
|
|
|
|
|
QXLOG(@"========app已经进入后台========");
|
|
|
|
|
|
if ([QXGlobal.shareGlobal.roomId isExist]) {
|
|
|
|
|
|
[[QXGiftPlayerManager shareManager] stopPlay];
|
2025-10-25 19:38:29 +08:00
|
|
|
|
[[QXGiftDisplayManager sharedManager] inBackGround];
|
2025-10-20 09:43:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
-(void)applicationWillResignActive:(UIApplication *)application{
|
|
|
|
|
|
QXLOG(@"========app即将进入后台========");
|
|
|
|
|
|
}
|
|
|
|
|
|
-(void)applicationWillEnterForeground:(UIApplication *)application{
|
2025-10-25 19:38:29 +08:00
|
|
|
|
if ([QXGlobal.shareGlobal.roomId isExist]) {
|
2025-10-20 09:43:10 +08:00
|
|
|
|
[[QXGiftPlayerManager shareManager] startPlay];
|
2025-10-25 19:38:29 +08:00
|
|
|
|
[[QXGiftDisplayManager sharedManager] becomeFront];
|
2025-10-20 09:43:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-08-08 10:49:36 +08:00
|
|
|
|
|
|
|
|
|
|
/// 设备转向
|
|
|
|
|
|
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
|
|
|
|
|
|
// ZFInterfaceOrientationMask orientationMask = [ZFLandscapeRotationManager supportedInterfaceOrientationsForWindow:window];
|
|
|
|
|
|
// if (orientationMask != ZFInterfaceOrientationMaskUnknow) {
|
|
|
|
|
|
// return (UIInterfaceOrientationMask)orientationMask;
|
|
|
|
|
|
// }
|
|
|
|
|
|
/// 这里是非播放器VC支持的方向
|
|
|
|
|
|
if (_allowRotate == 1) {
|
|
|
|
|
|
return UIInterfaceOrientationMaskLandscapeRight;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return UIInterfaceOrientationMaskPortrait;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 返回是否支持设备自动旋转
|
|
|
|
|
|
- (BOOL)shouldAutorotate
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_allowRotate == 1) {
|
|
|
|
|
|
return YES;
|
|
|
|
|
|
}
|
|
|
|
|
|
return NO;
|
|
|
|
|
|
}
|
|
|
|
|
|
#pragma mark - TIMPush
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - TIMPush
|
|
|
|
|
|
- (int)businessID {
|
|
|
|
|
|
//上一步控制台给的证书ID,如 1234567
|
|
|
|
|
|
return AppPushId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//- (NSString *)applicationGroupID {
|
|
|
|
|
|
// //AppGroup ID
|
|
|
|
|
|
// return kTIMPushAppGroupKey;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
- (BOOL)onRemoteNotificationReceived:(NSString *)notice {
|
|
|
|
|
|
// custom navigate
|
|
|
|
|
|
return NO;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - TIMPushListener
|
|
|
|
|
|
- (void)onNotificationClicked:(NSString *)ext {
|
|
|
|
|
|
// 获取 ext 自定义跳转
|
|
|
|
|
|
}
|
|
|
|
|
|
@end
|