添加网络检测

This commit is contained in:
fengshuo
2022-12-27 10:48:47 +08:00
parent 67ce3f7329
commit 95a13228a1

View File

@@ -10,6 +10,7 @@
#import <NIMSDK/NIMSDK.h>
#import <Masonry/Masonry.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AFNetworkReachabilityManager.h>
#import <POP.h>
///Tool
#import "XPMacro.h"
@@ -83,6 +84,7 @@ UIKIT_EXTERN NSString * kUserCompleteInfoFinishKey;
NSString * const kUserFirstLoginKey = @"kUserFirstLoginKey";
NSString * const kHadLaunchApp = @"kHadLaunchApp";
NSString * const kLastShowAnchorCardTime = @"kLastShowAnchorCardTime";
NSString * const kNetworkReachabilityKey = @"kNetworkReachabilityKey";
UIKIT_EXTERN NSString * kNewUserRechargeKey;
UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
@@ -109,7 +111,6 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
@property (nonatomic,strong) NSMutableArray<XPRoomGiftBroadCastModel *> *giftBroadcastQueue;
///
@property (nonatomic, assign) BOOL parentMode;
@end
@implementation TabbarViewController
@@ -125,6 +126,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
[[NIMSDK sharedSDK].broadcastManager addDelegate:self];
[self.presenter getVersionUpdate];
[self.presenter juliandAdCallBackApi];
[self networkReachability];
[self.view addSubview:self.roomMineView];
[[NSNotificationCenter defaultCenter] addObserverForName:kRoomMiniNotificationKey object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
[self configRoomMiniNView:note.userInfo];
@@ -269,6 +271,30 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
}
}
#pragma mark -
- (void)networkReachability{
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case AFNetworkReachabilityStatusUnknown:
break;
case AFNetworkReachabilityStatusNotReachable:
break;
case AFNetworkReachabilityStatusReachableViaWWAN:
case AFNetworkReachabilityStatusReachableViaWiFi:
{
[[NSNotificationCenter defaultCenter] postNotificationName:kNetworkReachabilityKey object:nil userInfo:nil];
[self.presenter autoLogin];
[self.presenter getVersionUpdate];
[[ClientConfig shareConfig] clientInit];
}
break;
default:
break;
}
}];
}
#pragma mark - BaseMvpProtocol
- (void)tokenInvalid {
LoginViewController *lvc = [[LoginViewController alloc] init];