// // AppDelegate.m // Asteria // // Created by iOS on 2023/4/22. // #import "AppDelegate.h" #import "AS_TabBarViewController.h" #import @interface AppDelegate () //@property (nonatomic, strong, readonly) UIWindow *window; @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. if (@available(iOS 15.0, *)) { UITableView.appearance.sectionHeaderTopPadding = 0; } else { // Fallback on earlier versions } [ASCurrencyManager.shared getAllCurrencyData]; // [self xxx_ytkNetConfig]; [PPNetworkHelper openLog]; self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; AS_TabBarViewController *tab = [[AS_TabBarViewController alloc] init]; tab.selectedIndex = 0; self.window.rootViewController = tab; if (ASUserInfoManager.shared.isLogin ) { [ASUserInfoManager.shared getInfo]; } [ASNetTools reqNet_getAdvCoupons]; [self.window makeKeyAndVisible]; return YES; } -(void)xxx_ytkNetConfig{ YTKNetworkAgent *agent = [YTKNetworkAgent sharedAgent]; [agent setValue:[NSSet setWithObjects:@"application/json", @"text/html", @"text/json", @"text/plain", @"text/javascript", @"text/xml", @"image/*",@"image/jpeg",@"image/jpg",@"image/png",@"application/x-javascript",nil] forKeyPath:@"_manager.responseSerializer.acceptableContentTypes"]; YTKNetworkConfig *config = [YTKNetworkConfig sharedConfig]; config.securityPolicy.allowInvalidCertificates = YES; config.securityPolicy.validatesDomainName = NO; config.baseUrl = [NSString stringWithFormat:@"%@",AS_Server]; NSLog(@"baseUrl-----%@",config.baseUrl) } - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { NSLog(@"--------userInfo:%@",userInfo); // completionHandler(UIBackgroundFetchResultNewData); [self handlePush:userInfo]; } #pragma mark - dealwith push data /// 处理来自远程的推送内容 - (void)handlePush:(NSDictionary *)payLoad { if (payLoad == nil) { return; } NSDictionary *aps = [payLoad valueForKey:@"aps"]; if (aps == nil) { return; } UIApplication *application = [UIApplication sharedApplication]; // 当前 APP 在前台 if (application.applicationState == UIApplicationStateActive || application.applicationState == UIApplicationStateBackground) { //活动状态下使用消息提示再提示一下,让用户可以点击 // 备注:这边比较特殊,当 APP 在前台时,当推送来的时候,会来到这个方法,当点击推送弹窗后,这个方法会再次调用,即这个方法会调用两次,走两次 push 操作. NSLog(@"payLoad=%@",payLoad); // [self handlePushAction:payLoad]; // 处理推送消息 } else { [self handlePushAction:payLoad]; // 处理推送消息 } } - (void)handlePushAction:(NSDictionary *)payLoad { NSDictionary *customData = payLoad[@"custom"][@"a"]; NSString *title = customData[@"title"]; NSString *push_para = customData[@"push_para"]; NSString *message_id = customData[@"message_id"]; NSNumber *push_type = customData[@"push_type"]; if (!push_type) { return; } NSInteger type = push_type.integerValue; // [[KWPushMessageHandler shareInstance] handleMessage:title messageId:message_id pushPara:push_para pushType:type]; } @end