AppDelegate+sdk.m 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // AppDelegate+sdk.m
  3. // Overseas Watch
  4. //
  5. // Created by 刘振兴 on 2023/11/28.
  6. // Copyright © 2023 BaH Cy. All rights reserved.
  7. //
  8. #import "AppDelegate+sdk.h"
  9. #import <FBSDKCoreKit/FBSDKCoreKit.h>
  10. #import <GoogleSignIn/GoogleSignIn.h>
  11. #import <UMMobClick/MobClick.h>
  12. #import <Bugly/Bugly.h>
  13. #import "IQKeyboardManager.h"
  14. #import "IanAdsStartView.h"
  15. #import "SKWebViewViewController.h"
  16. @implementation AppDelegate (sdk)
  17. + (void)initSdk:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  18. //[MobClick setLogEnabled:YES];
  19. UMConfigInstance.appKey = @"55a46a7667e58ef87a004b64";
  20. UMConfigInstance.secret = @"secretstringaldfkals";
  21. [MobClick startWithConfigure:UMConfigInstance];
  22. [Bugly startWithAppId:@"b77c7f7dbd"];
  23. #ifdef SK_DEBUG_GOOGLE_FACEBOOK
  24. //plist 中添加
  25. [[GIDSignIn sharedInstance] restorePreviousSignInWithCompletion:^(GIDGoogleUser * _Nullable user, NSError * _Nullable error) {
  26. }];
  27. //TMO 第三方登录
  28. [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
  29. [FBSDKProfile setIsUpdatedWithAccessTokenChange:YES];
  30. #endif
  31. }
  32. + (void)initIQKeyboard {
  33. //自动伸缩键盘
  34. IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
  35. manager.enable = YES;
  36. manager.shouldResignOnTouchOutside = YES;
  37. manager.shouldToolbarUsesTextFieldTintColor = YES;
  38. manager.enableAutoToolbar = NO;
  39. }
  40. + (void)showAdvertising {
  41. //开屏广告
  42. NSString *adsString = [[NSUserDefaults standardUserDefaults] objectForKey:@"Key_LaunchAds"];
  43. //@"http://785j3g.com1.z0.glb.clouddn.com/d659db60-f.jpg";
  44. if ([adsString isKindOfClass:[NSNull class]] || adsString == nil || [adsString isEqualToString:@""])
  45. return;
  46. NSDictionary* adsDic = [SKUtil parseString2Dictionary:adsString];
  47. NSString* picUrl = adsDic[@"ImageUrl"];
  48. if ([picUrl isKindOfClass:[NSNull class]] || picUrl != nil || [picUrl isEqualToString:@""])
  49. return;
  50. IanAdsStartView *startView = [IanAdsStartView startAdsViewWithBgImageUrl:picUrl withClickImageAction:^{
  51. NSString *title = adsDic[@"Title"];
  52. NSString *url = adsDic[@"AdUrl"];
  53. UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
  54. SKWebViewViewController *webVc = [storyboard instantiateViewControllerWithIdentifier:@"WebViewVC"];
  55. webVc.title = title;
  56. webVc.urlToOpen = url;
  57. webVc.mIsShare = YES;
  58. webVc.mIsOpenApp = YES;
  59. [SKUtil pushViewController:webVc animated:YES];
  60. }];
  61. [startView startAnimationTime:3 WithCompletionBlock:^(IanAdsStartView *startView){
  62. NSLog(@"广告结束后,执行事件");
  63. }];
  64. }
  65. + (void)monitorNetworking {
  66. [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
  67. switch (status) {
  68. case AFNetworkReachabilityStatusUnknown://未知网络
  69. case AFNetworkReachabilityStatusNotReachable://网络不可达
  70. HDNormalLog(@"NETWORK --> 0");
  71. [[NSNotificationCenter defaultCenter] postNotificationName:@"MONITORS_NETWORKING_STATUS" object:@(0)];
  72. break;
  73. case AFNetworkReachabilityStatusReachableViaWWAN://GPRS网络
  74. case AFNetworkReachabilityStatusReachableViaWiFi://wifi网络
  75. HDNormalLog(@"NETWORK --> 1");
  76. [[NSNotificationCenter defaultCenter] postNotificationName:@"MONITORS_NETWORKING_STATUS" object:@(1)];
  77. break;
  78. }
  79. }];
  80. [[AFNetworkReachabilityManager sharedManager] startMonitoring];
  81. }
  82. + (void)create3DTouch {
  83. NSMutableArray *arrShortcutItem = (NSMutableArray *)[UIApplication sharedApplication].shortcutItems;
  84. if (arrShortcutItem.count <= 0) {
  85. UIApplicationShortcutItem *shoreItem1 = [[UIApplicationShortcutItem alloc] initWithType:@"3DTouch.Btn.First" localizedTitle:NSLocalizedString(@"Location.Btn.Call", nil) localizedSubtitle:nil icon:[UIApplicationShortcutIcon iconWithTemplateImageName:@"3DTouch1"] userInfo:nil];
  86. [arrShortcutItem addObject:shoreItem1];
  87. UIApplicationShortcutItem *shoreItem2 = [[UIApplicationShortcutItem alloc] initWithType:@"3DTouch.Btn.Second" localizedTitle:NSLocalizedString(@"Tabbar.Chat", nil) localizedSubtitle:nil icon:[UIApplicationShortcutIcon iconWithTemplateImageName:@"3DTouch2"] userInfo:nil];
  88. [arrShortcutItem addObject:shoreItem2];
  89. UIApplicationShortcutItem *shoreItem3 = [[UIApplicationShortcutItem alloc] initWithType:@"3DTouch.Btn.Third" localizedTitle:NSLocalizedString(@"Tabbar.Watch", nil) localizedSubtitle:nil icon:[UIApplicationShortcutIcon iconWithTemplateImageName:@"3DTouch3"] userInfo:nil];
  90. [arrShortcutItem addObject:shoreItem3];
  91. [UIApplication sharedApplication].shortcutItems = arrShortcutItem;
  92. }
  93. }
  94. - (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler {
  95. if (@available(iOS 9.0, *)) {
  96. if ([[SKDataManager shared] getChildCount] <= 0)
  97. return;
  98. if ([shortcutItem.type isEqualToString:@"3DTouch.Btn.First"]) {
  99. NSString* phoneNum = [SKDataManager shared].mSelectChildModel.phoneNumber;
  100. if (phoneNum == nil || [phoneNum length] <= 0 )
  101. return;
  102. //E164
  103. NSString* nationCode = [SKDataManager shared].mSelectChildModel.areaCode;
  104. phoneNum = [SKUtil parsePhoneNumber:phoneNum countryCode:nationCode];
  105. phoneNum = [@"tel://" stringByAppendingString:phoneNum];
  106. if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:phoneNum]]) {
  107. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNum] options:@{} completionHandler:^(BOOL success) {
  108. }];
  109. }
  110. } else if ([shortcutItem.type isEqualToString:@"3DTouch.Btn.Second"]) {
  111. UIViewController* controller = [UIApplication sharedApplication].keyWindow.rootViewController;
  112. UITabBarController* tabbar = (UITabBarController*)controller;
  113. if (tabbar) {
  114. [tabbar setSelectedIndex:1];
  115. }
  116. } else if ([shortcutItem.type isEqualToString:@"3DTouch.Btn.Third"]) {
  117. UIViewController* controller = [UIApplication sharedApplication].keyWindow.rootViewController;
  118. UITabBarController* tabbar = (UITabBarController*)controller;
  119. if (tabbar) {
  120. [tabbar setSelectedIndex:2];
  121. }
  122. }
  123. }
  124. }
  125. @end