| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 | 
							- //
 
- //  ThirdPartService.m
 
- //  westkissMob
 
- //
 
- //  Created by 王猛 on 2022/9/5.
 
- //
 
- #import "ThirdPartService.h"
 
- #import <IQKeyboardManager/IQKeyboardManager.h>
 
- // 检测网络状态
 
- #import <Reachability/Reachability.h>
 
- @interface ThirdPartService()
 
- @property (strong, nonatomic) Reachability *internetReachability;
 
- @end
 
- @implementation ThirdPartService
 
- + (instancetype)sharedInstance {
 
-     static id sharedInstance = nil;
 
-     static dispatch_once_t onceToken;
 
-     dispatch_once(&onceToken, ^{
 
-         sharedInstance = [[self alloc] init];
 
-     });
 
-     return sharedInstance;
 
- }
 
- + (void)load{
 
-     [[ThirdPartService sharedInstance] setupKeyboardManager];
 
-     [[ThirdPartService sharedInstance] setupReachability];
 
- }
 
- #pragma mark - 设置全局键盘
 
- - (void)setupKeyboardManager {
 
-     // 设置键盘监听管理
 
-     IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
 
-     manager.toolbarDoneBarButtonItemText =@"Done";
 
-     manager.enable=YES;
 
-     manager.toolbarManageBehaviour =IQAutoToolbarByTag;
 
-     manager.shouldResignOnTouchOutside=NO;
 
-     manager.shouldToolbarUsesTextFieldTintColor=NO;
 
-     manager.enableAutoToolbar=YES;
 
-     manager.shouldShowToolbarPlaceholder = NO;
 
-     manager.shouldResignOnTouchOutside = YES; // 控制点击背景是否收起键盘
 
- }
 
- #pragma mark - 检测网络状态
 
- - (void)setupReachability {
 
-     //添加一个系统通知
 
-     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];
 
-     //初始化
 
-     self.internetReachability=[Reachability reachabilityForInternetConnection];
 
-     //通知添加到Run Loop
 
-     [self.internetReachability startNotifier];
 
-     [self updateInterfaceWithReachability:_internetReachability];
 
- }
 
- - (void)reachabilityChanged:(NSNotification *)note {
 
-     Reachability* curReach = [note object];
 
-     if ([curReach isKindOfClass:[Reachability class]]) {
 
-         NSParameterAssert([curReach isKindOfClass: [Reachability class]]);
 
-         [self updateInterfaceWithReachability: curReach];
 
-     } else {
 
-         UIViewController *topVc = topViewController();
 
-         [topVc.view makeToast:@"Network status has been switched."];
 
-     }
 
- }
 
- - (void)updateInterfaceWithReachability:(Reachability *)reachability {
 
-     NetworkStatus netStatus = [reachability currentReachabilityStatus];
 
-     UIViewController *topVc = topViewController();
 
-     [NSNotificationCenter.defaultCenter postNotificationName:netStatusUpdate object:nil];
 
-     switch (netStatus) {
 
-         case NotReachable:
 
-             NSLog(@"====当前网络状态不可达=======");
 
-             [topVc.view makeToast:@"Current network status is unavailable"];
 
-             break;
 
-         case ReachableViaWiFi:
 
-             NSLog(@"====当前网络状态为Wifi=======");
 
- //            [topVc.view makeToast:@"The current network status is WiFi."];
 
-             break;
 
-         case ReachableViaWWAN:
 
-             NSLog(@"====当前网络状态为蜂窝网络=======");
 
- //            [topVc.view makeToast:@"The current status is cellular network."];
 
-             break;
 
-     }
 
- }
 
- @end
 
 
  |