| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 | ////  AppDelegate.m//  Asteria////  Created by iOS on 2023/4/22.//#import "AppDelegate.h"#import "AS_TabBarViewController.h"#import <YTKNetwork/YTKNetwork.h>#import <FBSDKLoginKit/FBSDKLoginKit.h>#import <StripeCore/StripeCore-Swift.h>@import Stripe;@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    }            // 为了使用 Facebook SDK 应该调用如下方法   [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];   // 注册 FacebookAppID    [[FBSDKSettings sharedSettings] setAppID:Facebook_AppID];        [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];            [StripeAPI setDefaultPublishableKey:@"pk_test_51MFDGRAxgV55iyHtmJFrPuz4i5cl1y3nhTLVT3EmsHlYLIwsj7TnPRPeulAUXSbOW7gccaVLJmFjVz4eu3E17g6z00TLI1YvoG"];        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];        }#pragma mark - **************** applicationDelegate  ****************- (BOOL)application:(UIApplication *)app            openURL:(NSURL *)url            options:(NSDictionary *)options {        [[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options];          // nzk Google Signin    BOOL stripeHandled = [StripeAPI handleStripeURLCallbackWithURL:url];    if(stripeHandled){        return YES;    }    // nzk Google Signin end        return YES;}@end
 |