AppDelegate.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // AppDelegate.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/4/22.
  6. //
  7. #import "AppDelegate.h"
  8. #import "AS_TabBarViewController.h"
  9. #import <YTKNetwork/YTKNetwork.h>
  10. #import <FBSDKLoginKit/FBSDKLoginKit.h>
  11. #import <StripeCore/StripeCore-Swift.h>
  12. @import Stripe;
  13. @interface AppDelegate ()
  14. //@property (nonatomic, strong, readonly) UIWindow *window;
  15. @end
  16. @implementation AppDelegate
  17. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  18. // Override point for customization after application launch.
  19. if (@available(iOS 15.0, *)) {
  20. UITableView.appearance.sectionHeaderTopPadding = 0;
  21. } else {
  22. // Fallback on earlier versions
  23. }
  24. // 为了使用 Facebook SDK 应该调用如下方法
  25. [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
  26. // 注册 FacebookAppID
  27. [[FBSDKSettings sharedSettings] setAppID:Facebook_AppID];
  28. [ASCurrencyManager.shared getAllCurrencyData];
  29. // [self xxx_ytkNetConfig];
  30. [PPNetworkHelper openLog];
  31. self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
  32. AS_TabBarViewController *tab = [[AS_TabBarViewController alloc] init];
  33. tab.selectedIndex = 0;
  34. self.window.rootViewController = tab;
  35. if (ASUserInfoManager.shared.isLogin ) {
  36. [ASUserInfoManager.shared getInfo];
  37. }
  38. [ASNetTools reqNet_getAdvCoupons];
  39. [self.window makeKeyAndVisible];
  40. [StripeAPI setDefaultPublishableKey:@"pk_test_51MFDGRAxgV55iyHtmJFrPuz4i5cl1y3nhTLVT3EmsHlYLIwsj7TnPRPeulAUXSbOW7gccaVLJmFjVz4eu3E17g6z00TLI1YvoG"];
  41. return YES;
  42. }
  43. -(void)xxx_ytkNetConfig{
  44. YTKNetworkAgent *agent = [YTKNetworkAgent sharedAgent];
  45. [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"];
  46. YTKNetworkConfig *config = [YTKNetworkConfig sharedConfig];
  47. config.securityPolicy.allowInvalidCertificates = YES;
  48. config.securityPolicy.validatesDomainName = NO;
  49. config.baseUrl = [NSString stringWithFormat:@"%@",AS_Server];
  50. NSLog(@"baseUrl-----%@",config.baseUrl)
  51. }
  52. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
  53. NSLog(@"--------userInfo:%@",userInfo);
  54. // completionHandler(UIBackgroundFetchResultNewData);
  55. [self handlePush:userInfo];
  56. }
  57. #pragma mark - dealwith push data
  58. /// 处理来自远程的推送内容
  59. - (void)handlePush:(NSDictionary *)payLoad {
  60. if (payLoad == nil) {
  61. return;
  62. }
  63. NSDictionary *aps = [payLoad valueForKey:@"aps"];
  64. if (aps == nil) {
  65. return;
  66. }
  67. UIApplication *application = [UIApplication sharedApplication];
  68. // 当前 APP 在前台
  69. if (application.applicationState == UIApplicationStateActive || application.applicationState == UIApplicationStateBackground) { //活动状态下使用消息提示再提示一下,让用户可以点击
  70. // 备注:这边比较特殊,当 APP 在前台时,当推送来的时候,会来到这个方法,当点击推送弹窗后,这个方法会再次调用,即这个方法会调用两次,走两次 push 操作.
  71. NSLog(@"payLoad=%@",payLoad);
  72. // [self handlePushAction:payLoad]; // 处理推送消息
  73. } else {
  74. [self handlePushAction:payLoad]; // 处理推送消息
  75. }
  76. }
  77. - (void)handlePushAction:(NSDictionary *)payLoad {
  78. NSDictionary *customData = payLoad[@"custom"][@"a"];
  79. NSString *title = customData[@"title"];
  80. NSString *push_para = customData[@"push_para"];
  81. NSString *message_id = customData[@"message_id"];
  82. NSNumber *push_type = customData[@"push_type"];
  83. if (!push_type) {
  84. return;
  85. }
  86. NSInteger type = push_type.integerValue;
  87. // [[KWPushMessageHandler shareInstance] handleMessage:title messageId:message_id pushPara:push_para pushType:type];
  88. }
  89. #pragma mark - **************** applicationDelegate ****************
  90. - (BOOL)application:(UIApplication *)app
  91. openURL:(NSURL *)url
  92. options:(NSDictionary *)options {
  93. [[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options];
  94. // nzk Google Signin
  95. BOOL stripeHandled = [StripeAPI handleStripeURLCallbackWithURL:url];
  96. if(stripeHandled){
  97. return YES;
  98. }
  99. // nzk Google Signin end
  100. return YES;
  101. }
  102. @end