2023-07-14 18:50:55 +08:00
|
|
|
|
//
|
|
|
|
|
// ViewController.m
|
|
|
|
|
// YUMI
|
|
|
|
|
//
|
|
|
|
|
// Created by admin on 2023/3/9.
|
|
|
|
|
//
|
|
|
|
|
#import <UIKit/UIKit.h>
|
|
|
|
|
///Third
|
|
|
|
|
#import <ReactiveObjC/ReactiveObjC.h>
|
|
|
|
|
#import <NIMSDK/NIMSDK.h>
|
|
|
|
|
#import <Masonry/Masonry.h>
|
|
|
|
|
#import <AudioToolbox/AudioToolbox.h>
|
|
|
|
|
#import <AFNetworkReachabilityManager.h>
|
|
|
|
|
#import <POP.h>
|
2023-07-18 18:26:10 +08:00
|
|
|
|
#import <AFNetworking.h>
|
2024-11-13 11:20:56 +08:00
|
|
|
|
#import "SDWebImageManager.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///Tool
|
|
|
|
|
#import "YUMIMacroUitls.h"
|
|
|
|
|
#import "DJDKMIMOMColor.h"
|
|
|
|
|
#import "UIImage+Utils.h"
|
|
|
|
|
#import "NSObject+MJExtension.h"
|
|
|
|
|
#import "XNDJTDDLoadingTool.h"
|
|
|
|
|
#import "AccountInfoStorage.h"
|
|
|
|
|
#import "TTPopup.h"
|
|
|
|
|
#import "YUMIConstant.h"
|
|
|
|
|
#import "XPRoomMiniManager.h"
|
|
|
|
|
#import "ClientConfig.h"
|
|
|
|
|
#import "RtcManager.h"
|
|
|
|
|
#import "XCCurrentVCStackManager.h"
|
|
|
|
|
#import "Api+Home.h"
|
|
|
|
|
#import "YUMIConstant.h"
|
2024-07-17 17:49:33 +08:00
|
|
|
|
#import "Api+Moments.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#import "XPAdImageTool.h"
|
|
|
|
|
#import "YYUtility.h"
|
|
|
|
|
#import "PLTimeUtil.h"
|
2024-05-31 19:56:25 +08:00
|
|
|
|
#import "Api+MSRoomGameApi.h"
|
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///Model
|
2024-05-31 19:56:25 +08:00
|
|
|
|
#import "MSRoomGameModel.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#import "AccountModel.h"
|
|
|
|
|
#import "RoomInfoModel.h"
|
|
|
|
|
#import "AttachmentModel.h"
|
|
|
|
|
#import "XPMineVisitorUnReadModel.h"
|
|
|
|
|
#import "InviteUserInfoModel.h"
|
|
|
|
|
#import "NewUserGreetModel.h"
|
|
|
|
|
#import "FindNewGreetMessageModel.h"
|
|
|
|
|
#import "XPTabAnchorCardModel.h"
|
|
|
|
|
#import "FirstRechargeModel.h"
|
|
|
|
|
#import "MonentsUnReadModel.h"
|
2023-10-26 15:20:20 +08:00
|
|
|
|
#import "XPRedPacketModel.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#import "GiftReceiveInfoModel.h"
|
|
|
|
|
#import "XPVersionUpdateModel.h"
|
2024-05-31 19:56:25 +08:00
|
|
|
|
#import "MSRoomGameQuitGameView.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///VC
|
|
|
|
|
#import "TabbarViewController.h"
|
|
|
|
|
#import "XPBlankViewController.h"
|
2025-03-14 19:43:04 +08:00
|
|
|
|
#import "LoginViewController.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#import "BaseNavigationController.h"
|
|
|
|
|
#import "LoginBindPhoneViewController.h"
|
|
|
|
|
#import "LoginFullInfoViewController.h"
|
|
|
|
|
#import "XPMineViewController.h"
|
2023-09-22 12:20:43 +08:00
|
|
|
|
#import "XPSessionMainViewController.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#import "XPMiniRoomView.h"
|
|
|
|
|
#import "XPRoomViewController.h"
|
|
|
|
|
#import "XPSessionFindNewAlertView.h"
|
|
|
|
|
#import "XPAnchorCardView.h"
|
|
|
|
|
#import "XPTaskCompleteTipView.h"
|
|
|
|
|
#import "XPWebViewController.h"
|
|
|
|
|
#import "XPMineUserInfoViewController.h"
|
2025-04-10 18:01:01 +08:00
|
|
|
|
#import "LudoGameViewController.h"
|
2024-05-31 19:56:25 +08:00
|
|
|
|
#import "MSRoomGameVC.h"
|
2024-05-22 19:06:21 +08:00
|
|
|
|
|
2024-07-17 17:49:33 +08:00
|
|
|
|
#import "XPMomentsRecommendViewController.h"
|
2024-06-17 17:20:08 +08:00
|
|
|
|
#import "XPMomentsViewController.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#import "XPReceiveRedPacketView.h"
|
|
|
|
|
#import "XPRoomYearActivityView.h"
|
|
|
|
|
#import "XPUpgradeView.h"
|
2023-08-14 14:39:41 +08:00
|
|
|
|
#import "XPLoginAuthCodeVC.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///Present
|
|
|
|
|
#import "MainPresenter.h"
|
|
|
|
|
#import "MainProtocol.h"
|
|
|
|
|
#import "RoomHostDelegate.h"
|
|
|
|
|
#import "XPSkillCardPlayerManager.h"
|
2025-01-22 21:22:58 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#import <SVGA.h>
|
2023-07-18 18:26:10 +08:00
|
|
|
|
#import "Api+Gift.h"
|
2024-03-26 14:56:55 +08:00
|
|
|
|
#import "UploadFile.h"
|
2024-05-31 19:56:25 +08:00
|
|
|
|
#import "XPTabBar.h"
|
2023-10-24 10:48:57 +08:00
|
|
|
|
|
2024-06-17 17:20:08 +08:00
|
|
|
|
#import "XPHomePagingViewController.h"
|
2023-10-24 10:48:57 +08:00
|
|
|
|
|
2024-09-27 11:17:04 +08:00
|
|
|
|
#import "IAPManager.h"
|
2024-10-10 20:16:23 +08:00
|
|
|
|
#import "RoomBoomManager.h"
|
|
|
|
|
#import "RoomBoomBannerAnimation.h"
|
2024-09-27 11:17:04 +08:00
|
|
|
|
|
2024-12-28 15:41:56 +08:00
|
|
|
|
#import "RoomResourceManager.h"
|
2025-03-21 16:19:07 +08:00
|
|
|
|
#import "SocialShareManager.h"
|
2025-08-08 17:01:59 +08:00
|
|
|
|
#import "PublicRoomManager.h"
|
2024-12-28 15:41:56 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
NSString * const kUserFirstLoginKey = @"kUserFirstLoginKey";
|
|
|
|
|
NSString * const kHadLaunchApp = @"kHadLaunchApp";
|
|
|
|
|
NSString * const kLastShowAnchorCardTime = @"kLastShowAnchorCardTime";
|
|
|
|
|
NSString * const kNetworkReachabilityKey = @"kNetworkReachabilityKey";
|
|
|
|
|
UIKIT_EXTERN NSString * kNewUserRechargeKey;
|
|
|
|
|
UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
|
|
|
|
|
2025-01-22 21:22:58 +08:00
|
|
|
|
@interface TabbarViewController () <BaseMvpProtocol, MainProtocol, NIMLoginManagerDelegate, NIMSystemNotificationManagerDelegate, NIMChatManagerDelegate,XPLoginAuthCodeVCDelegate, XPAnchorCardViewDelegate, NIMBroadcastManagerDelegate, MSRoomGameQuitGameViewDelegate>
|
2023-10-07 16:21:47 +08:00
|
|
|
|
///用户信息
|
2023-10-07 18:42:30 +08:00
|
|
|
|
@property (nonatomic,strong) UserInfoModel *userInfo;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
@property (nonatomic, strong) MainPresenter *presenter;
|
|
|
|
|
///房间最小化
|
|
|
|
|
@property (nonatomic,strong) XPMiniRoomView *roomMineView;
|
|
|
|
|
///需要显示新用户充值优惠弹窗
|
|
|
|
|
@property (nonatomic, assign) BOOL needShowNewUserRecharge;
|
|
|
|
|
///需要展示主播卡片(首次)
|
|
|
|
|
@property (nonatomic, assign) BOOL needShowAnchorCard;
|
|
|
|
|
///延迟弹出主播卡片
|
|
|
|
|
@property (nonatomic, assign) BOOL delayShowAnchorCard;
|
|
|
|
|
///主播卡片
|
|
|
|
|
@property (nonatomic, strong) XPAnchorCardView *anchorCardView;
|
|
|
|
|
///任务完成提示
|
|
|
|
|
@property (nonatomic, strong) XPTaskCompleteTipView *taskTipView;
|
|
|
|
|
///是否是的第一次链接网络
|
|
|
|
|
@property (nonatomic,assign) BOOL isFirstReachability;
|
|
|
|
|
///是否刷新了
|
|
|
|
|
@property (nonatomic,assign) BOOL isReload;
|
2023-09-27 12:35:29 +08:00
|
|
|
|
///是否刷新了
|
|
|
|
|
@property (nonatomic,assign) BOOL isInitReload;
|
2023-11-20 14:25:47 +08:00
|
|
|
|
@property(nonatomic,assign) BOOL isReloadTicket;
|
2023-07-21 14:07:04 +08:00
|
|
|
|
|
2024-12-28 15:41:56 +08:00
|
|
|
|
@property(nonatomic, assign) NSInteger retryCount;
|
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation TabbarViewController
|
2024-11-05 17:09:22 +08:00
|
|
|
|
|
2023-10-07 16:21:47 +08:00
|
|
|
|
- (void)dealloc{
|
|
|
|
|
[[NSNotificationCenter defaultCenter]removeObserver:self];
|
|
|
|
|
[[NIMSDK sharedSDK].loginManager removeDelegate:self];
|
|
|
|
|
[[NIMSDK sharedSDK].chatManager removeDelegate:self];
|
|
|
|
|
[[NIMSDK sharedSDK].systemNotificationManager removeDelegate:self];
|
|
|
|
|
[[NIMSDK sharedSDK].broadcastManager removeDelegate:self];
|
|
|
|
|
}
|
2024-11-05 17:09:22 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
- (void)viewDidLoad {
|
2023-07-18 18:26:10 +08:00
|
|
|
|
[super viewDidLoad];
|
2024-06-03 10:51:16 +08:00
|
|
|
|
|
2024-09-03 20:22:54 +08:00
|
|
|
|
self.tabBarController.tabBar.translucent = NO;
|
|
|
|
|
|
2023-10-10 15:45:37 +08:00
|
|
|
|
[self.presenter autoLogin];
|
2024-11-28 10:40:21 +08:00
|
|
|
|
[self initTabs:NO defaultSelectedIndex:0];
|
2024-06-17 17:20:08 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
[[NIMSDK sharedSDK].loginManager addDelegate:self];
|
2023-07-18 18:26:10 +08:00
|
|
|
|
[[NIMSDK sharedSDK].chatManager addDelegate:self];
|
|
|
|
|
[[NIMSDK sharedSDK].systemNotificationManager addDelegate:self];
|
|
|
|
|
[[NIMSDK sharedSDK].broadcastManager addDelegate:self];
|
2024-10-10 20:16:23 +08:00
|
|
|
|
|
2023-07-18 18:26:10 +08:00
|
|
|
|
[self.view addSubview:self.roomMineView];
|
2024-06-17 17:20:08 +08:00
|
|
|
|
|
2023-10-07 18:42:30 +08:00
|
|
|
|
@kWeakify(self);
|
2023-07-18 18:26:10 +08:00
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserverForName:kRoomMiniNotificationKey object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
|
2023-10-07 18:42:30 +08:00
|
|
|
|
@kStrongify(self);
|
2023-07-18 18:26:10 +08:00
|
|
|
|
[self configRoomMiniNView:note.userInfo];
|
|
|
|
|
}];
|
2024-06-17 17:20:08 +08:00
|
|
|
|
|
2024-11-05 17:09:22 +08:00
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserverForName:@"reloadAfterLoadConfig"
|
|
|
|
|
object:nil
|
|
|
|
|
queue:nil
|
|
|
|
|
usingBlock:^(NSNotification * _Nonnull note) {
|
2023-10-07 18:42:30 +08:00
|
|
|
|
@kStrongify(self);
|
2023-09-27 12:35:29 +08:00
|
|
|
|
if (self.isInitReload == NO) {
|
2024-11-28 10:40:21 +08:00
|
|
|
|
[self initTabs:YES defaultSelectedIndex:0];
|
2023-07-18 18:26:10 +08:00
|
|
|
|
self.isReload = YES;
|
|
|
|
|
}
|
|
|
|
|
}];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showNewUserRecharge) name:kNewUserRechargeKey object:nil];
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showAnchorCardKey:) name:kTabShowAnchorCardKey object:nil];
|
2024-04-08 18:55:15 +08:00
|
|
|
|
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(switchLanguage:) name:@"kSwitchLanguage" object:nil];
|
2024-10-10 20:16:23 +08:00
|
|
|
|
|
2024-11-05 17:09:22 +08:00
|
|
|
|
[[ClientConfig shareConfig] setUpdateTabbarBG:^(UIImage * _Nonnull image) {
|
|
|
|
|
@kStrongify(self);
|
|
|
|
|
[self configTheme:image];
|
|
|
|
|
}];
|
|
|
|
|
|
2024-11-06 17:57:32 +08:00
|
|
|
|
[self configTheme:[[ClientConfig shareConfig] tabbarBGImage]];
|
|
|
|
|
|
2024-10-10 20:16:23 +08:00
|
|
|
|
[[RoomBoomManager sharedManager] registerBoomBanner:^(id _Nonnull sth) {
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
2024-10-23 19:08:51 +08:00
|
|
|
|
[RoomBoomBannerAnimation display:kWindow
|
2024-11-05 17:09:22 +08:00
|
|
|
|
with:sth
|
|
|
|
|
tapToRoom:YES
|
2024-10-23 19:08:51 +08:00
|
|
|
|
complete:^{}];
|
2024-10-10 20:16:23 +08:00
|
|
|
|
});
|
|
|
|
|
} target:self];
|
2025-03-21 16:19:07 +08:00
|
|
|
|
|
|
|
|
|
[self registerSocialCallBack];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)registerSocialCallBack {
|
2025-04-10 18:01:01 +08:00
|
|
|
|
// 注册分享回调事件
|
2025-05-19 19:27:53 +08:00
|
|
|
|
|
|
|
|
|
[[SocialShareManager sharedManager] setHandleJumpToRoom:^(ShareItmeInfo * _Nonnull shareItem) {
|
2025-06-18 16:28:13 +08:00
|
|
|
|
// 添加类型安全检查,防止NSTaggedPointerString错误
|
|
|
|
|
if (![shareItem isKindOfClass:[ShareItmeInfo class]]) {
|
|
|
|
|
NSLog(@"警告:shareItem不是ShareItmeInfo类型,而是%@类型", NSStringFromClass([shareItem class]));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-19 19:27:53 +08:00
|
|
|
|
switch (shareItem.shareType) {
|
|
|
|
|
case 1: { // 跳转到房间
|
|
|
|
|
NSString *roomID = shareItem.targetUid;
|
|
|
|
|
if (![NSString isEmpty:roomID]) {
|
|
|
|
|
//判断是否在房间
|
|
|
|
|
__block BOOL isInRoom = NO;
|
|
|
|
|
__block XPRoomViewController *currentRoom;
|
|
|
|
|
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
|
if ([obj isKindOfClass:[XPRoomViewController class]]) {
|
|
|
|
|
currentRoom = obj;
|
|
|
|
|
*stop = YES;
|
|
|
|
|
isInRoom = YES;
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
// 如果有 mini 房间
|
|
|
|
|
if (isInRoom == NO && [XPRoomMiniManager shareManager].getRoomInfo) {
|
|
|
|
|
@kWeakify(self);
|
|
|
|
|
[TTPopup alertWithMessage:YMLocalizedString(@"Combo_10") confirmHandler:^{
|
|
|
|
|
@kStrongify(self);
|
|
|
|
|
[[RtcManager instance] exitRoom];
|
|
|
|
|
[[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId] completion:nil];
|
|
|
|
|
[self.roomMineView hiddenRoomMiniView];
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
[XPRoomViewController openRoom:roomID
|
|
|
|
|
viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
|
|
|
|
});
|
|
|
|
|
} cancelHandler:^{}];
|
|
|
|
|
} else if (isInRoom && ![currentRoom isSameRoom:roomID]) {
|
|
|
|
|
[TTPopup alertWithMessage:YMLocalizedString(@"Combo_10") confirmHandler:^{
|
|
|
|
|
[currentRoom exitRoom];
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
[XPRoomViewController openRoom:roomID
|
|
|
|
|
viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
|
|
|
|
});
|
|
|
|
|
} cancelHandler:^{}];
|
|
|
|
|
} else {
|
2025-03-21 16:19:07 +08:00
|
|
|
|
[XPRoomViewController openRoom:roomID
|
|
|
|
|
viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
2025-05-19 19:27:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 2: // 跳转到活动
|
|
|
|
|
{
|
|
|
|
|
XPWebViewController * webVC = [[XPWebViewController alloc] initWithRoomUID:nil];
|
|
|
|
|
webVC.url = [NSString stringWithFormat:@"%@%@",
|
|
|
|
|
URLWithType(kEventDetailPath),
|
|
|
|
|
shareItem.targetId];
|
|
|
|
|
[self.navigationController pushViewController:webVC animated:YES];
|
2025-03-21 16:19:07 +08:00
|
|
|
|
}
|
2025-05-19 19:27:53 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2025-03-21 16:19:07 +08:00
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)unsignSocialCallback {
|
|
|
|
|
[[SocialShareManager sharedManager] reset];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-07-05 17:15:16 +08:00
|
|
|
|
|
2024-04-08 18:55:15 +08:00
|
|
|
|
-(void)switchLanguage:(NSNotification *)not{
|
2024-11-28 10:40:21 +08:00
|
|
|
|
[self initTabs:YES defaultSelectedIndex:4];
|
2024-04-08 18:55:15 +08:00
|
|
|
|
}
|
2024-07-05 17:15:16 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
2023-11-20 14:25:47 +08:00
|
|
|
|
self.isReloadTicket = YES;
|
2023-07-18 18:26:10 +08:00
|
|
|
|
if ([XPRoomMiniManager shareManager].getRoomInfo == nil) {
|
|
|
|
|
[self.roomMineView hiddenRoomMiniView];
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
|
|
[super viewWillDisappear:animated];
|
|
|
|
|
self.delayShowAnchorCard = NO;
|
|
|
|
|
[self.anchorCardView removeFromSuperview];
|
|
|
|
|
self.anchorCardView = nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (MainPresenter *)presenter {
|
|
|
|
|
if (_presenter == nil) {
|
|
|
|
|
_presenter = [[MainPresenter alloc] init];
|
|
|
|
|
[_presenter attatchView:self];
|
|
|
|
|
}
|
|
|
|
|
return _presenter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 登录成功(通过token且换取ticket后)。
|
|
|
|
|
|
2023-07-18 18:26:10 +08:00
|
|
|
|
1. 登录云信。
|
|
|
|
|
2. 获取用户信息。
|
|
|
|
|
3. 其实目前多余回调V层,可以在P层里自行做这个逻辑。
|
2023-07-14 18:50:55 +08:00
|
|
|
|
*/
|
|
|
|
|
- (void)autoLoginSuccess {
|
|
|
|
|
[self.presenter loginNIM];
|
|
|
|
|
[self.presenter getUserInfo];
|
2024-12-28 15:41:56 +08:00
|
|
|
|
|
2025-01-07 20:07:54 +08:00
|
|
|
|
[[UploadFile share] initQCloud];
|
2024-09-27 11:17:04 +08:00
|
|
|
|
|
2023-07-18 18:26:10 +08:00
|
|
|
|
///检查更新
|
2024-05-22 19:23:54 +08:00
|
|
|
|
[self.presenter getVersionUpdate];
|
|
|
|
|
|
|
|
|
|
if (self.inviteCode && self.inviteCode.length > 0) {
|
|
|
|
|
///邀请码进房
|
|
|
|
|
[self.presenter checkInviteUserInfo:self.inviteCode];
|
2023-07-18 18:26:10 +08:00
|
|
|
|
}
|
|
|
|
|
[self requestGiftList];
|
2024-12-28 15:41:56 +08:00
|
|
|
|
[self cacheRoomResource];
|
2023-07-18 18:26:10 +08:00
|
|
|
|
|
|
|
|
|
XPAdImageTool.shareImageTool.isImLogin = YES;
|
|
|
|
|
|
2024-05-22 19:23:54 +08:00
|
|
|
|
if ([self hadLaunchApp] && [self canShowAnchorCard]) {
|
2024-11-05 17:09:22 +08:00
|
|
|
|
@kWeakify(self);
|
2024-05-22 19:23:54 +08:00
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
2024-11-05 17:09:22 +08:00
|
|
|
|
@kStrongify(self);
|
2024-05-22 19:23:54 +08:00
|
|
|
|
if (self.view.window && self.isViewLoaded) {
|
|
|
|
|
[self.presenter getAnchorCardInfo];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (self.needShowAnchorCard && !self.delayShowAnchorCard) {
|
|
|
|
|
[self.presenter getAnchorCardInfo];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kHadLaunchApp];///第一次弹主播卡片
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
2023-07-18 18:26:10 +08:00
|
|
|
|
}
|
2024-09-27 11:17:04 +08:00
|
|
|
|
|
|
|
|
|
[[IAPManager sharedManager] handleLogin];
|
|
|
|
|
[[IAPManager sharedManager] retryCheckAllReceipt];
|
2025-08-14 18:04:38 +08:00
|
|
|
|
|
|
|
|
|
// 统一入口:1秒后进入公共房间
|
|
|
|
|
// @kWeakify(self);
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
// @kStrongify(self);
|
|
|
|
|
NSLog(@"TabbarViewController: 统一入口 - 开始进入公共房间");
|
|
|
|
|
[[PublicRoomManager sharedManager] enterPublicRoomWithCompletion:^(NSError * _Nullable error) {
|
|
|
|
|
if (error) {
|
|
|
|
|
NSLog(@"TabbarViewController: 进入公共房间失败: %@", error);
|
|
|
|
|
} else {
|
|
|
|
|
NSLog(@"TabbarViewController: 进入公共房间成功");
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
});
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2025-01-07 20:07:54 +08:00
|
|
|
|
|
2024-05-31 19:56:25 +08:00
|
|
|
|
-(void)getRoomGameInfo{
|
2024-06-03 18:59:43 +08:00
|
|
|
|
[Api getRoomGameDetailsForHoem:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
2024-05-31 19:56:25 +08:00
|
|
|
|
if(code == 200){
|
|
|
|
|
MSRoomGameModel *model = [MSRoomGameModel modelWithJSON:data.data];
|
|
|
|
|
if(model.data.matchStatus == 1 && model.data.roundStatus == 0){
|
|
|
|
|
MSTabbarRoomGameItemModel *chooseGameModel = [MSTabbarRoomGameItemModel new];
|
|
|
|
|
chooseGameModel.scores = model.data.scores;
|
|
|
|
|
chooseGameModel.roomId = model.roomId;
|
|
|
|
|
MSRoomGameQuitGameView *quitGameView = [[MSRoomGameQuitGameView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
|
|
|
|
quitGameView.chooseGameModel = chooseGameModel;
|
|
|
|
|
quitGameView.delegate = self;
|
|
|
|
|
[TTPopup popupView:quitGameView style:TTPopupStyleAlert];
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-03 18:59:43 +08:00
|
|
|
|
}];
|
2024-05-31 19:56:25 +08:00
|
|
|
|
}
|
|
|
|
|
#pragma mark -MSRoomGameQuitGameViewDelegate
|
|
|
|
|
///退出游戏
|
|
|
|
|
- (void)closeGameActionWithModel:(MSTabbarRoomGameItemModel *)model{
|
|
|
|
|
[Api closeRoomGame:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
|
|
|
|
|
|
|
|
} roomId:model.roomId];
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
|
2024-05-31 19:56:25 +08:00
|
|
|
|
///强杀app打开后,是否重新玩游戏
|
|
|
|
|
-(void)replayTheGameWithModel:(MSTabbarRoomGameItemModel *)model{
|
|
|
|
|
MSRoomGameVC *gameVC = [MSRoomGameVC new];
|
|
|
|
|
|
|
|
|
|
gameVC.chooseGameModel = model;
|
|
|
|
|
gameVC.userinfo = self.userInfo;
|
|
|
|
|
BaseNavigationController *nav = [[BaseNavigationController alloc]initWithRootViewController:gameVC];
|
|
|
|
|
nav.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
|
|
[self presentViewController:nav animated:YES completion:nil];
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
/// 获取用户信息后检查:1、是否绑定手机号;2、是否需要完善用户信息。
|
|
|
|
|
/// 该逻辑仅在刷新ticket后执行一次。
|
|
|
|
|
/// 当前服务端接口是有未完善信息的全局拦截的,在BaseMvpPresenter里会触发1415去完善用户信息。
|
|
|
|
|
- (void)getUserInfoSuccess:(UserInfoModel *)userInfo {
|
2024-07-18 19:03:11 +08:00
|
|
|
|
if (!userInfo.isBindPhone && [ClientConfig shareConfig].iOSPhoneBind) {
|
2023-07-14 18:50:55 +08:00
|
|
|
|
LoginBindPhoneViewController * bindPhoneVC = [[LoginBindPhoneViewController alloc] init];
|
|
|
|
|
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:bindPhoneVC];
|
|
|
|
|
nav.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
|
|
[self.navigationController presentViewController:nav animated:YES completion:nil];
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-10-07 16:21:47 +08:00
|
|
|
|
self.userInfo = userInfo;
|
2024-12-03 17:40:29 +08:00
|
|
|
|
[[XPSkillCardPlayerManager shareInstance] setUserInfoModel:userInfo];
|
2025-04-21 13:52:13 +08:00
|
|
|
|
[[XPSkillCardPlayerManager shareInstance] requestBravoGiftTabInfomation];
|
2024-10-12 19:30:41 +08:00
|
|
|
|
[[RoomBoomManager sharedManager] saveUserInfo:userInfo];
|
2025-08-08 17:01:59 +08:00
|
|
|
|
|
2025-08-14 18:04:38 +08:00
|
|
|
|
// 初始化PublicRoomManager并更新用户信息
|
|
|
|
|
[[PublicRoomManager sharedManager] initialize];
|
2025-08-08 17:01:59 +08:00
|
|
|
|
[[PublicRoomManager sharedManager] updateUserInfo:userInfo];
|
|
|
|
|
|
2024-05-31 19:56:25 +08:00
|
|
|
|
[self getRoomGameInfo];
|
2023-11-23 10:56:01 +08:00
|
|
|
|
[AccountInfoStorage instance].name = self.userInfo.nick;
|
2024-05-22 19:23:54 +08:00
|
|
|
|
|
2023-10-07 16:21:47 +08:00
|
|
|
|
if ((userInfo.nick == nil || userInfo.avatar == nil) && self.isFormLogin == NO) {
|
2023-11-20 19:29:01 +08:00
|
|
|
|
[self completeUserInfo];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2024-05-22 19:23:54 +08:00
|
|
|
|
|
|
|
|
|
if(self.isReload == NO){
|
2024-11-28 10:40:21 +08:00
|
|
|
|
[self initTabs:YES defaultSelectedIndex:0];
|
2024-05-22 19:23:54 +08:00
|
|
|
|
self.isInitReload = YES;
|
2023-09-27 12:35:29 +08:00
|
|
|
|
}
|
2023-10-08 16:46:12 +08:00
|
|
|
|
|
2024-05-22 19:23:54 +08:00
|
|
|
|
if (self.inviteCode.length <= 0) {
|
|
|
|
|
[self initQuickEnterRoom];
|
2023-07-18 18:26:10 +08:00
|
|
|
|
}
|
2024-05-15 17:35:51 +08:00
|
|
|
|
|
2024-05-22 19:23:54 +08:00
|
|
|
|
if (self.inviteCode) {
|
|
|
|
|
self.inviteCode = nil;
|
|
|
|
|
}
|
2024-05-15 17:35:51 +08:00
|
|
|
|
|
2024-05-22 19:23:54 +08:00
|
|
|
|
[self monentsUnReadCount];
|
2023-10-07 16:21:47 +08:00
|
|
|
|
}
|
2025-01-07 20:07:54 +08:00
|
|
|
|
|
2023-10-07 16:21:47 +08:00
|
|
|
|
-(void)loginIng{
|
|
|
|
|
if ((self.userInfo.nick == nil || self.userInfo.avatar == nil) && self.isFormLogin == NO) {
|
|
|
|
|
[self completeUserInfo];
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-05-22 19:23:54 +08:00
|
|
|
|
|
2023-10-07 18:42:30 +08:00
|
|
|
|
if(self.isReload == NO){
|
2024-11-28 10:40:21 +08:00
|
|
|
|
[self initTabs:YES defaultSelectedIndex:0];
|
2023-10-07 18:42:30 +08:00
|
|
|
|
self.isInitReload = YES;
|
2023-10-07 16:21:47 +08:00
|
|
|
|
}
|
2024-05-22 19:23:54 +08:00
|
|
|
|
|
|
|
|
|
if (self.inviteCode.length <= 0) {
|
|
|
|
|
[self initQuickEnterRoom];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (self.inviteCode) {
|
|
|
|
|
self.inviteCode = nil;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-05-22 19:23:54 +08:00
|
|
|
|
|
|
|
|
|
[self monentsUnReadCount];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2025-01-07 20:07:54 +08:00
|
|
|
|
|
2023-08-14 14:39:41 +08:00
|
|
|
|
- (void)getAuthorizationCodeInfoWithPhonefail{
|
|
|
|
|
[self completeUserInfo];
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-05 17:09:22 +08:00
|
|
|
|
-(void)getAuthorizationCodeInfoWithPhoneSuccess:(BOOL)flag {
|
2023-08-14 14:39:41 +08:00
|
|
|
|
if(flag == NO){
|
|
|
|
|
XPLoginAuthCodeVC *vc = [[XPLoginAuthCodeVC alloc]init];
|
|
|
|
|
vc.delegate = self;
|
|
|
|
|
vc.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
|
|
[self presentViewController:vc animated:YES completion:nil];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
[self completeUserInfo];
|
|
|
|
|
}
|
2024-11-05 17:09:22 +08:00
|
|
|
|
|
2023-08-14 14:39:41 +08:00
|
|
|
|
#pragma mark - XPLoginAuthCodeVCDelegate
|
|
|
|
|
- (void)bindCodeSuccess{
|
|
|
|
|
[self completeUserInfo];
|
|
|
|
|
}
|
2024-05-17 11:27:36 +08:00
|
|
|
|
///缓存礼物特效
|
2023-07-18 18:26:10 +08:00
|
|
|
|
-(void)requestGiftList{
|
2024-05-17 11:27:36 +08:00
|
|
|
|
@kWeakify(self);
|
2024-05-23 17:21:40 +08:00
|
|
|
|
AFNetworkReachabilityManager *networkManager = [AFNetworkReachabilityManager sharedManager];
|
|
|
|
|
[networkManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
2024-05-17 11:27:36 +08:00
|
|
|
|
@kStrongify(self);
|
2024-05-23 17:21:40 +08:00
|
|
|
|
if (status == AFNetworkReachabilityStatusReachableViaWiFi) {
|
|
|
|
|
if(self.isFirstReachability == NO){
|
|
|
|
|
[Api requestCacheGiftDynamicEffectList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
|
|
|
if(code == 200){
|
|
|
|
|
self.isFirstReachability = YES;
|
|
|
|
|
NSArray *allResourceList = data.data;
|
|
|
|
|
NSSet *allResourceSet = [[NSSet alloc] initWithArray:allResourceList];
|
2024-11-05 17:09:22 +08:00
|
|
|
|
NSMutableArray *allResourceURLs = @[].mutableCopy;
|
2024-05-23 17:21:40 +08:00
|
|
|
|
for (NSString *url in allResourceSet) {
|
2024-11-28 10:40:21 +08:00
|
|
|
|
if (![NSString isEmpty:url]) {
|
|
|
|
|
[allResourceURLs addObject:url];
|
|
|
|
|
}
|
2024-05-17 11:27:36 +08:00
|
|
|
|
}
|
2024-05-23 17:21:40 +08:00
|
|
|
|
[[UploadFile share] startBatchDownloadWithURLs:allResourceURLs];
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
} else {
|
|
|
|
|
[[UploadFile share] resumeBatchDownload];
|
2023-07-18 18:26:10 +08:00
|
|
|
|
}
|
2024-05-23 17:21:40 +08:00
|
|
|
|
} else {
|
|
|
|
|
[[UploadFile share] pauseBatchDownload];
|
2023-07-18 18:26:10 +08:00
|
|
|
|
}
|
2023-07-21 14:07:04 +08:00
|
|
|
|
}];
|
2024-05-23 17:21:40 +08:00
|
|
|
|
[networkManager startMonitoring];
|
2024-05-15 17:35:51 +08:00
|
|
|
|
}
|
2024-05-21 16:19:10 +08:00
|
|
|
|
|
2025-05-07 19:30:50 +08:00
|
|
|
|
- (void)requestFaceList {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-28 15:41:56 +08:00
|
|
|
|
- (void)cacheRoomResource {
|
|
|
|
|
[Api requestRoomResource:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
|
|
|
if (code == 200) {
|
|
|
|
|
[[RoomResourceManager sharedManager] cacheAPIData:data.data];
|
|
|
|
|
} else {
|
|
|
|
|
if (self.retryCount <= 5) {
|
|
|
|
|
self.retryCount += 1;
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * self.retryCount * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
[self cacheRoomResource];
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-07-18 18:26:10 +08:00
|
|
|
|
}
|
2024-12-28 15:41:56 +08:00
|
|
|
|
}];
|
2023-07-18 18:26:10 +08:00
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
|
|
|
|
|
- (void)checkInviteUserInfoSuccess:(InviteUserInfoModel *)inviteInfo {
|
2024-05-15 17:35:51 +08:00
|
|
|
|
if (inviteInfo && inviteInfo.isInRoom) {
|
|
|
|
|
[XPRoomViewController openRoom:inviteInfo.roomUid fromNick:inviteInfo.inviteNick fromType:inviteInfo.fromType fromUid:inviteInfo.inviteUid viewController:self];
|
|
|
|
|
} else { //不在房间
|
|
|
|
|
[self.presenter getShortCutRecommendRoom];
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)getShortCutRecommendRoomSuccces:(NSString *)roomUid {
|
2024-05-15 17:35:51 +08:00
|
|
|
|
if (roomUid.length > 0) {
|
|
|
|
|
[XPRoomViewController openRoom:roomUid viewController:self];
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - app 启动调用此接口 主要功能: 给主播分流
|
|
|
|
|
- (void)clientStartApp {
|
2025-02-05 18:15:41 +08:00
|
|
|
|
// [self.presenter clientStartApp];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - BaseMvpProtocol
|
|
|
|
|
- (void)tokenInvalid {
|
2025-03-14 19:43:04 +08:00
|
|
|
|
LoginViewController *lvc = [[LoginViewController alloc] init];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:lvc];
|
|
|
|
|
nav.modalPresentationStyle = UIModalPresentationFullScreen;
|
2023-10-07 16:21:47 +08:00
|
|
|
|
kWindow.rootViewController = nav;
|
2024-05-15 17:35:51 +08:00
|
|
|
|
XPAdImageTool.shareImageTool.isImLogin = NO;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)completeUserInfo {
|
|
|
|
|
LoginFullInfoViewController * bindPhoneVC = [[LoginFullInfoViewController alloc] init];
|
|
|
|
|
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:bindPhoneVC];
|
|
|
|
|
nav.modalPresentationStyle = UIModalPresentationFullScreen;
|
2023-10-07 18:42:30 +08:00
|
|
|
|
kWindow.rootViewController = nav;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///获取主播卡片信息成功
|
|
|
|
|
- (void)getAnchorCardInfoSuccess:(XPTabAnchorCardModel *)cardInfo {
|
|
|
|
|
if (!self.anchorCardView.superview && cardInfo && self.isViewLoaded && self.view.window) {
|
|
|
|
|
self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90);
|
|
|
|
|
[UIView animateWithDuration:0.5 animations:^{
|
|
|
|
|
self.anchorCardView.frame = CGRectMake(0, kStatusBarHeight, KScreenWidth, 90);
|
|
|
|
|
} completion:nil];
|
|
|
|
|
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);//默认震动效果
|
|
|
|
|
long time = (long)([[NSDate date] timeIntervalSince1970]*1000);
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:@(time) forKey:kLastShowAnchorCardTime];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
|
self.anchorCardView.cardInfo = cardInfo;
|
|
|
|
|
[self.view addSubview:self.anchorCardView];
|
|
|
|
|
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleAnchorCardSwipeFrom:)];
|
|
|
|
|
[recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
|
|
|
|
|
[self.anchorCardView addGestureRecognizer:recognizer];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///获取更新版本信息成功
|
|
|
|
|
- (void)getVersionUpdate:(XPVersionUpdateModel *)versionModel {
|
2024-05-15 17:35:51 +08:00
|
|
|
|
XPUpgradeView *view = [[XPUpgradeView alloc] init];
|
|
|
|
|
view.versionModel = versionModel;
|
|
|
|
|
TTPopupService * service = [[TTPopupService alloc] init];
|
|
|
|
|
service.contentView = view;
|
|
|
|
|
service.shouldDismissOnBackgroundTouch = NO;
|
|
|
|
|
[TTPopup popupWithConfig:service];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - NIMLoginManagerDelegate
|
|
|
|
|
- (void)onAutoLoginFailed:(NSError *)error {
|
|
|
|
|
// 如果非上次登录设备 autoLogin 会返回 417
|
|
|
|
|
if (error.code == 417) {
|
|
|
|
|
@weakify(self);
|
|
|
|
|
AccountModel* accountModel = [AccountInfoStorage instance].getCurrentAccountInfo;
|
|
|
|
|
[[NIMSDK sharedSDK].loginManager login:accountModel.uid token:accountModel.netEaseToken completion:^(NSError * _Nullable error) {
|
|
|
|
|
if (error) {
|
|
|
|
|
@strongify(self);
|
|
|
|
|
[self.presenter logout];
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
[self.presenter logout];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)onKickout:(NIMLoginKickoutResult *)result {
|
2024-05-15 17:35:51 +08:00
|
|
|
|
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"TabbarViewController0")];
|
|
|
|
|
UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
|
|
|
|
|
if ([rootViewController presentedViewController]) { //有一个被present出来的控制器 要先dismiss
|
|
|
|
|
[[rootViewController presentedViewController] dismissViewControllerAnimated:YES completion:^{
|
|
|
|
|
if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) {
|
|
|
|
|
[[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES];
|
|
|
|
|
}
|
|
|
|
|
if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) {
|
|
|
|
|
UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
|
|
|
|
|
if (tabVC.selectedViewController.navigationController) {
|
|
|
|
|
[tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES];
|
|
|
|
|
}
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
[tabVC setSelectedIndex:0];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}else { //不是被present出来的 就有可能是rootvc或者是被push出来的 所以要判断nav是不是只有一个vc 如果有多个就pop
|
|
|
|
|
if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) {
|
|
|
|
|
[[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES];
|
|
|
|
|
}
|
|
|
|
|
if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) {
|
|
|
|
|
UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
|
|
|
|
|
if (tabVC.selectedViewController) {
|
|
|
|
|
if ([tabVC.selectedViewController isKindOfClass:[UINavigationController class]]) {
|
|
|
|
|
[tabVC.selectedViewController popToRootViewControllerAnimated:YES];
|
|
|
|
|
} else {
|
|
|
|
|
[tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES];
|
|
|
|
|
}
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
[tabVC setSelectedIndex:0];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ([XPRoomMiniManager shareManager].getRoomInfo) {
|
|
|
|
|
[[RtcManager instance] exitRoom];
|
|
|
|
|
[[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId] completion:nil];
|
|
|
|
|
[self.roomMineView hiddenRoomMiniView];
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
[self.presenter logout];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - NIMChatManagerDelegate
|
|
|
|
|
|
|
|
|
|
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
|
2024-05-22 19:23:54 +08:00
|
|
|
|
if ([AccountInfoStorage instance].getTicket.length == 0) {
|
2023-07-14 18:50:55 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2024-05-15 17:35:51 +08:00
|
|
|
|
for (NIMMessage * message in messages) {
|
|
|
|
|
if (message.session.sessionType == NIMSessionTypeP2P) {
|
|
|
|
|
if(message.messageType == NIMMessageTypeCustom) {
|
|
|
|
|
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
|
|
|
|
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
|
|
|
|
AttachmentModel * attachment = (AttachmentModel *)obj.attachment;
|
|
|
|
|
if (attachment.first == CustomMessageType_FindNew && attachment.second == Custom_Message_Find_New_Greet_New_User) {
|
|
|
|
|
FindNewGreetMessageModel * greetInfo = [FindNewGreetMessageModel modelWithDictionary:attachment.data];
|
|
|
|
|
if (greetInfo.uid.integerValue != [AccountInfoStorage instance].getUid.integerValue) {
|
|
|
|
|
[TTPopup dismiss];
|
|
|
|
|
XPSessionFindNewAlertView * alertView = [[XPSessionFindNewAlertView alloc] init];
|
|
|
|
|
alertView.userInfo = greetInfo;
|
|
|
|
|
TTPopupService *service = [[TTPopupService alloc] init];
|
|
|
|
|
service.contentView = alertView;
|
|
|
|
|
service.shouldDismissOnBackgroundTouch = NO;
|
|
|
|
|
service.style = TTPopupStyleAlert;
|
|
|
|
|
[TTPopup popupWithConfig:service];
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-05-15 17:35:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-05-15 17:35:51 +08:00
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)onReceiveBroadcastMessage:(NIMBroadcastMessage *)broadcastMessage {
|
2024-05-22 19:23:54 +08:00
|
|
|
|
if ([AccountInfoStorage instance].getUid.length == 0) {
|
2024-05-15 17:35:51 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (broadcastMessage.content) {
|
|
|
|
|
NSDictionary *msgDictionary = [broadcastMessage.content toJSONObject];
|
|
|
|
|
AttachmentModel *attachment = [AttachmentModel modelWithJSON:msgDictionary[@"body"]];
|
2024-04-24 20:08:24 +08:00
|
|
|
|
NSString *partitionId = [NSString stringWithFormat:@"%@",attachment.data[@"partitionId"]];
|
|
|
|
|
if(![partitionId isEqualToString:self.userInfo.partitionId]){
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-10-10 20:16:23 +08:00
|
|
|
|
|
2025-04-02 11:04:07 +08:00
|
|
|
|
// NSLog(@" --- Broadcast Message Raw Attach Content: %@", msgDictionary);
|
2024-10-10 20:16:23 +08:00
|
|
|
|
|
2024-05-22 19:23:54 +08:00
|
|
|
|
// MARK: 要复查这里的 if else 嵌套
|
2024-05-15 17:35:51 +08:00
|
|
|
|
if (attachment.first == CustomMessageType_RedPacket) {
|
2023-10-25 19:26:20 +08:00
|
|
|
|
[self receiveRedPacketDealWithData:attachment];
|
2025-01-22 21:22:58 +08:00
|
|
|
|
} else if(attachment.first == CustomMessageType_Version_Update && attachment.second == Custom_Message_Version_Update_Value){
|
2024-05-15 17:35:51 +08:00
|
|
|
|
NSString *osValue = attachment.data[@"updateOs"];
|
|
|
|
|
if([osValue isEqualToString:@"ios"] && [AccountInfoStorage instance].getUid.length > 0){
|
|
|
|
|
XPVersionUpdateModel *updateModel = [XPVersionUpdateModel modelWithDictionary:attachment.data];
|
|
|
|
|
[self getVersionUpdate:updateModel];
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-05-15 17:35:51 +08:00
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2023-10-25 19:26:20 +08:00
|
|
|
|
///收到红包,处理数据
|
|
|
|
|
-(void)receiveRedPacketDealWithData:(AttachmentModel *)attachment{
|
2023-10-26 15:20:20 +08:00
|
|
|
|
if(attachment.second != Custom_Message_Sub_AllDiamandRedPacket)return;
|
|
|
|
|
XPRedPacketModel *data = [XPRedPacketModel modelWithDictionary:attachment.data];
|
|
|
|
|
data.validityType = 0;
|
|
|
|
|
data.kind = 1;
|
2023-10-27 16:17:05 +08:00
|
|
|
|
data.redEnvelopeId = attachment.data[@"redEnvelopeId"];
|
2023-10-25 19:26:20 +08:00
|
|
|
|
//判断是否在房间
|
|
|
|
|
__block BOOL isInRoom;
|
2024-11-05 17:09:22 +08:00
|
|
|
|
|
2023-10-25 19:26:20 +08:00
|
|
|
|
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
|
if ([obj isKindOfClass:[XPRoomViewController class]]) {
|
2023-10-27 16:17:05 +08:00
|
|
|
|
*stop = YES;
|
2023-10-27 17:21:23 +08:00
|
|
|
|
isInRoom = YES;
|
2023-10-25 19:26:20 +08:00
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
if (!isInRoom) {
|
|
|
|
|
UIViewController *currentVc = [[XCCurrentVCStackManager shareManager] getCurrentVC];
|
|
|
|
|
XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
|
|
|
|
view.inAllPacketRoom = NO;
|
2023-10-26 15:20:20 +08:00
|
|
|
|
view.receiveModel = data;
|
2023-10-25 19:26:20 +08:00
|
|
|
|
[currentVc.view addSubview:view];
|
|
|
|
|
[currentVc.view bringSubviewToFront:view];
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///判断是否在房间
|
|
|
|
|
-(BOOL)isInRoomWithData{
|
|
|
|
|
//判断是否在房间
|
|
|
|
|
__block BOOL isInRoom;
|
|
|
|
|
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
|
if ([obj isKindOfClass:[XPRoomViewController class]]) {
|
|
|
|
|
*stop = YES;
|
|
|
|
|
isInRoom = YES;
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
return isInRoom;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 收到消息被撤回的通知
|
|
|
|
|
*
|
|
|
|
|
* @param notification 被撤回的消息信息
|
|
|
|
|
* @discusssion 云信在收到消息撤回后,会先从本地数据库中找到对应消息并进行删除,之后通知上层消息已删除
|
|
|
|
|
*/
|
|
|
|
|
- (void)onRecvRevokeMessageNotification:(NIMRevokeMessageNotification *)notification {
|
2024-05-15 17:35:51 +08:00
|
|
|
|
NIMMessage * message = notification.message;
|
|
|
|
|
if (message) {
|
|
|
|
|
NIMMessage * revokeMessage = [[NIMMessage alloc] init];
|
|
|
|
|
[revokeMessage setValue:message.session forKey:@"session"];
|
|
|
|
|
[revokeMessage setValue:@(NIMMessageTypeTip) forKey:@"messageType"];
|
|
|
|
|
revokeMessage.timestamp = [PLTimeUtil getNowTimeTimestampMillisecond].longLongValue;
|
|
|
|
|
revokeMessage.text = YMLocalizedString(@"TabbarViewController1");
|
|
|
|
|
[[NIMSDK sharedSDK].conversationManager saveMessage:revokeMessage forSession:message.session completion:nil];
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-05 17:09:22 +08:00
|
|
|
|
- (void)configTheme:(UIImage *)image {
|
|
|
|
|
if (image == nil) {
|
|
|
|
|
image = kImage(@"tab_bar_bg");
|
|
|
|
|
}
|
|
|
|
|
[self.tabBar setBackgroundImage:image];
|
|
|
|
|
[self.tabBar setShadowImage:[[UIImage alloc]init]];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
if (@available(iOS 10.0, *)) {
|
2024-11-05 17:09:22 +08:00
|
|
|
|
[self.tabBar setUnselectedItemTintColor:[DJDKMIMOMColor tabbarNormalColor]];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-09-03 20:22:54 +08:00
|
|
|
|
|
|
|
|
|
if (@available(iOS 13, *)) {
|
|
|
|
|
UITabBarAppearance *tabBarAppearance = [UITabBarAppearance new];
|
2024-11-05 17:09:22 +08:00
|
|
|
|
tabBarAppearance.backgroundImage = image;
|
|
|
|
|
[self.tabBar setStandardAppearance:tabBarAppearance];
|
2024-09-03 20:22:54 +08:00
|
|
|
|
if (@available(iOS 15, *)) {
|
2024-11-05 17:09:22 +08:00
|
|
|
|
[self.tabBar setScrollEdgeAppearance:tabBarAppearance];
|
2024-09-03 20:22:54 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-28 10:40:21 +08:00
|
|
|
|
- (void)initTabs:(BOOL)isLogin defaultSelectedIndex:(NSInteger)index {
|
|
|
|
|
self.viewControllers = @[[XPBlankViewController new]];
|
2024-06-17 17:20:08 +08:00
|
|
|
|
// 创建视图控制器数组
|
2024-11-05 17:09:22 +08:00
|
|
|
|
NSMutableArray *viewControllers = [[NSMutableArray alloc] initWithCapacity:5];
|
|
|
|
|
for (NSInteger i = 0; i < 5; i++) {
|
2024-06-17 17:20:08 +08:00
|
|
|
|
UIViewController *viewController;
|
|
|
|
|
if (isLogin) {
|
|
|
|
|
switch (i) {
|
|
|
|
|
case 0:
|
|
|
|
|
viewController = [[XPHomePagingViewController alloc] init];
|
|
|
|
|
break;
|
2024-08-07 15:35:30 +08:00
|
|
|
|
case 1: {
|
|
|
|
|
@kWeakify(self);
|
2025-04-10 18:01:01 +08:00
|
|
|
|
LudoGameViewController *vc = [[LudoGameViewController alloc] init];
|
2024-08-07 15:35:30 +08:00
|
|
|
|
vc.needForceExitRoom = ^{
|
|
|
|
|
@kStrongify(self);
|
|
|
|
|
if ([XPRoomMiniManager shareManager].getRoomInfo) {
|
|
|
|
|
[[RtcManager instance] exitRoom];
|
|
|
|
|
[[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId]
|
|
|
|
|
completion:nil];
|
|
|
|
|
[self.roomMineView hiddenRoomMiniView];
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
viewController = vc;
|
|
|
|
|
}
|
2024-06-17 17:20:08 +08:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
viewController = [[XPMomentsViewController alloc] init];
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
viewController = [[XPSessionMainViewController alloc] init];
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
viewController = [[XPMineViewController alloc] init];
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
viewController = [[XPBlankViewController alloc] init]; // 兜底
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
viewController = [[XPBlankViewController alloc] init];
|
|
|
|
|
}
|
|
|
|
|
// 创建并设置标签栏项
|
2024-11-05 17:09:22 +08:00
|
|
|
|
[viewControllers addObject:[self createTabBarItem:viewController
|
|
|
|
|
title:[[ClientConfig shareConfig] tabName:i]
|
2024-11-13 14:21:00 +08:00
|
|
|
|
image:[[ClientConfig shareConfig] loadDefaultNormalTabImageName:i]
|
|
|
|
|
selectedImage:[[ClientConfig shareConfig] loadDefaultSelectedTabImageName:i]
|
2024-11-05 17:09:22 +08:00
|
|
|
|
index:i]];
|
2024-06-17 17:20:08 +08:00
|
|
|
|
}
|
|
|
|
|
// 设置视图控制器数组和默认选择项
|
|
|
|
|
self.viewControllers = [viewControllers copy];
|
2024-11-28 10:40:21 +08:00
|
|
|
|
self.selectedIndex = index;
|
2024-11-06 17:57:32 +08:00
|
|
|
|
|
2024-11-13 11:20:56 +08:00
|
|
|
|
if (isLogin) {
|
2024-11-28 11:05:57 +08:00
|
|
|
|
[self.viewControllers enumerateObjectsWithOptions:NSEnumerationConcurrent
|
|
|
|
|
usingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
|
NSString *urlString_1 = [[ClientConfig shareConfig] loadConfigNormalTabImagePath:idx];
|
|
|
|
|
if ([urlString_1 hasPrefix:@"http"]) {
|
|
|
|
|
[self loadCustomTabImage:urlString_1 targetVC:obj isForSelected:NO];
|
2024-11-13 11:20:56 +08:00
|
|
|
|
}
|
2024-11-28 11:05:57 +08:00
|
|
|
|
|
|
|
|
|
NSString *urlString_2 = [[ClientConfig shareConfig] loadConfigSelectedTabImagePath:idx];
|
|
|
|
|
if ([urlString_2 hasPrefix:@"http"]) {
|
|
|
|
|
[self loadCustomTabImage:urlString_2 targetVC:obj isForSelected:YES];
|
2024-11-13 11:20:56 +08:00
|
|
|
|
}
|
2024-11-28 11:05:57 +08:00
|
|
|
|
}];
|
2025-03-21 16:19:07 +08:00
|
|
|
|
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
[[SocialShareManager sharedManager] checkSocialShareItem];
|
|
|
|
|
});
|
2024-11-13 11:20:56 +08:00
|
|
|
|
}
|
2024-11-28 10:40:21 +08:00
|
|
|
|
}
|
2024-11-13 11:20:56 +08:00
|
|
|
|
|
2024-11-28 10:40:21 +08:00
|
|
|
|
- (void)loadCustomTabImage:(NSString *)imageURL
|
|
|
|
|
targetVC:(UIViewController *)targetVC
|
|
|
|
|
isForSelected:(BOOL)isSelected {
|
|
|
|
|
// 使用 SDWebImage 加载网络图片
|
|
|
|
|
[[SDWebImageManager sharedManager] loadImageWithURL:[NSURL URLWithString:imageURL]
|
|
|
|
|
options:SDWebImageRetryFailed | SDWebImageHighPriority | SDWebImageHighPriority
|
|
|
|
|
progress:nil
|
|
|
|
|
completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
|
|
|
|
|
if (image) {
|
2024-11-28 11:05:57 +08:00
|
|
|
|
CGSize iconSize = CGSizeMake(40, 40);
|
2024-11-28 10:40:21 +08:00
|
|
|
|
UIGraphicsBeginImageContextWithOptions(iconSize, NO, 0.0);
|
|
|
|
|
[image drawInRect:CGRectMake(0, 0, iconSize.width, iconSize.height)];
|
|
|
|
|
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
|
|
|
|
|
UIGraphicsEndImageContext();
|
|
|
|
|
|
|
|
|
|
// 更新 tabBarItem 的 image 和 selectedImage
|
|
|
|
|
if (isSelected) {
|
|
|
|
|
targetVC.tabBarItem.selectedImage = [resizedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
|
|
|
} else {
|
|
|
|
|
targetVC.tabBarItem.image = [resizedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-17 17:20:08 +08:00
|
|
|
|
- (BaseNavigationController *)createTabBarItem:(UIViewController *)itemVc
|
|
|
|
|
title:(NSString *)title
|
2024-11-05 17:09:22 +08:00
|
|
|
|
image:(NSString *)imageURL
|
|
|
|
|
selectedImage:(NSString *)selectedImageURL
|
|
|
|
|
index:(NSInteger)index {
|
|
|
|
|
itemVc.title = @"";
|
|
|
|
|
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x1F1B4F)}
|
2024-06-17 17:20:08 +08:00
|
|
|
|
forState:UIControlStateSelected];
|
2024-11-05 17:09:22 +08:00
|
|
|
|
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0xB8B7C7)}
|
2024-06-17 17:20:08 +08:00
|
|
|
|
forState:UIControlStateNormal];
|
2025-03-21 16:19:07 +08:00
|
|
|
|
|
|
|
|
|
itemVc.tabBarItem.image = [[UIImage imageNamed:imageURL] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
|
|
|
itemVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageURL] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
2024-11-06 17:57:32 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
BaseNavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:itemVc];
|
|
|
|
|
return nav;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - 动态
|
|
|
|
|
- (void)monentsUnReadCount {
|
2024-07-17 17:49:33 +08:00
|
|
|
|
[Api momentsUnReadCount:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
2024-05-15 17:35:51 +08:00
|
|
|
|
if (code == 200) {
|
|
|
|
|
MonentsUnReadModel * model = [MonentsUnReadModel modelWithDictionary:data.data];
|
|
|
|
|
NSString *badge = model.total > 0 ? @(model.total).stringValue : nil;
|
|
|
|
|
if (model.total > 99) {
|
|
|
|
|
badge = @"99+";
|
|
|
|
|
}
|
2024-05-31 19:56:25 +08:00
|
|
|
|
NSUInteger index = 2;
|
2024-05-15 17:35:51 +08:00
|
|
|
|
UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil;
|
|
|
|
|
[item setBadgeValue:badge];
|
|
|
|
|
}
|
|
|
|
|
} uid:[AccountInfoStorage instance].getUid];
|
2023-10-07 18:42:30 +08:00
|
|
|
|
NSArray *recentList = [[NIMSDK sharedSDK].conversationManager.allRecentSessions mutableCopy];
|
|
|
|
|
__block NSInteger unreadCount = 0;
|
|
|
|
|
NSMutableArray<NSString *> * uids = [[NSMutableArray alloc] init];
|
|
|
|
|
[recentList enumerateObjectsUsingBlock:^(NIMRecentSession * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
|
[uids addObject:obj.session.sessionId];
|
|
|
|
|
unreadCount += obj.unreadCount;
|
|
|
|
|
}];
|
2024-05-15 17:35:51 +08:00
|
|
|
|
if(unreadCount > 0){
|
2024-05-31 19:56:25 +08:00
|
|
|
|
NSUInteger index = 3;
|
2024-05-15 17:35:51 +08:00
|
|
|
|
UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil;
|
|
|
|
|
[item setBadgeValue:[NSString stringWithFormat:@"%ld",unreadCount]];
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - 房间最小化
|
|
|
|
|
- (void)configRoomMiniNView:(NSDictionary *)dic {
|
2024-05-15 17:35:51 +08:00
|
|
|
|
UserInfoModel * userInfo = [UserInfoModel modelWithDictionary:dic[@"userInfo"]];
|
2024-06-21 01:37:38 +08:00
|
|
|
|
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic[@"roomInfo"]];
|
2024-05-15 17:35:51 +08:00
|
|
|
|
NSMutableDictionary * microQueue = dic[@"microQueue"];
|
|
|
|
|
[self.roomMineView configRoomMiniView:roomInfo userInfo:userInfo micQueue:microQueue];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - 快捷进房
|
|
|
|
|
- (void)initQuickEnterRoom {
|
2024-07-22 19:29:12 +08:00
|
|
|
|
// MARK: API 成功后,没有后续动作,先屏蔽
|
|
|
|
|
// NSString * key = [NSString stringWithFormat:@"%@_%@", kUserFirstLoginKey, [AccountInfoStorage instance].getUid];
|
|
|
|
|
// BOOL isNotFirstLogin = [[NSUserDefaults standardUserDefaults] boolForKey:key];
|
|
|
|
|
// if (!isNotFirstLogin) {
|
2024-05-15 17:35:51 +08:00
|
|
|
|
///新用户
|
2024-07-22 19:29:12 +08:00
|
|
|
|
// [self.presenter getNewUserGreetInfo];
|
|
|
|
|
// }
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///跳转优先级 闪屏→linkedMe→邀请码→新用户打招呼引导→渠道指定房间
|
|
|
|
|
- (void)completeUserInfoFinish:(NSString *)inviteCode {
|
2024-05-15 17:35:51 +08:00
|
|
|
|
self.inviteCode = inviteCode;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
#pragma mark -NIMSystemNotificationManagerDelegate
|
|
|
|
|
- (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification {
|
2023-10-07 16:21:47 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
if (notification.receiverType == NIMSessionTypeP2P) {
|
|
|
|
|
if (notification.content != nil) {
|
|
|
|
|
NSData *jsonData = [notification.content dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
|
NSError *err;
|
|
|
|
|
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];
|
|
|
|
|
if(err) {
|
2025-04-02 11:04:07 +08:00
|
|
|
|
// NSLog(@"json解析失败:%@",err);
|
2023-07-14 18:50:55 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ([dic[@"first"] integerValue] == CustomMessageType_First_VisitorRecord){//访客记录数量更新提示
|
|
|
|
|
AttachmentModel *attachment = [AttachmentModel modelWithJSON:notification.content];
|
|
|
|
|
XPMineVisitorUnReadModel *model = [XPMineVisitorUnReadModel modelWithJSON:attachment.data];
|
|
|
|
|
if ([model isKindOfClass:XPMineVisitorUnReadModel.class]) {
|
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:kVisitorUnReadCountNotificationKey object:model];
|
|
|
|
|
}
|
|
|
|
|
} else if ([dic[@"first"] intValue] == CustomMessageType_Task_Complete && [dic[@"second"] intValue] == Custom_Message_Sub_TaskComplete) {///任务完成提醒
|
|
|
|
|
if ([dic isKindOfClass:[NSDictionary class]]) {
|
|
|
|
|
NSDictionary *dict = dic[@"data"];
|
2025-06-18 16:28:13 +08:00
|
|
|
|
[self handleActivityTaskTip:dict[@"taskCompleteMsg"] url:dict[@"taskUrl"]];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - 主播卡片弹窗
|
|
|
|
|
//新用户专享充值弹窗
|
|
|
|
|
- (void)showNewUserRecharge {
|
|
|
|
|
self.needShowNewUserRecharge = YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///展示主播卡片
|
|
|
|
|
- (void)showAnchorCardKey:(NSNotification *)noti {
|
|
|
|
|
NSDictionary * dic = noti.object;
|
|
|
|
|
self.delayShowAnchorCard = [[dic objectForKey:@"delayShow"] boolValue];
|
|
|
|
|
self.needShowAnchorCard = YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///判断第二次启动时弹出主播卡片
|
|
|
|
|
- (BOOL)hadLaunchApp {
|
|
|
|
|
return [[NSUserDefaults standardUserDefaults] valueForKey:kHadLaunchApp];
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-07 16:21:47 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
|
|
|
|
|
- (BOOL)canShowAnchorCard {
|
|
|
|
|
if ([[XPRoomMiniManager shareManager] getRoomInfo]) {//在房间时不弹
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
|
NSNumber *lastTime = [defaults objectForKey:kLastShowAnchorCardTime];
|
|
|
|
|
if ([lastTime longValue] < 1) {
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
NSDate *datenow = [NSDate date];//现在时间
|
|
|
|
|
long time2 = (long)([datenow timeIntervalSince1970]*1000);
|
|
|
|
|
long aTime = (time2 - [lastTime longValue]) / 1000;
|
|
|
|
|
if (aTime > 15*60) {
|
|
|
|
|
return YES;
|
|
|
|
|
} else {
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - 活动任务完成提示
|
|
|
|
|
- (void)handleActivityTaskTip:(NSString *)msg url:(NSString *)url {
|
|
|
|
|
if (!self.taskTipView.superview && url.length) {
|
|
|
|
|
[self.view addSubview:self.taskTipView];
|
|
|
|
|
self.taskTipView.desc = msg;
|
|
|
|
|
self.taskTipView.url = url;
|
|
|
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jumpToTask:)];
|
|
|
|
|
[self.taskTipView addGestureRecognizer:tap];
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
if (self.taskTipView.superview) {
|
|
|
|
|
[self.taskTipView removeFromSuperview];
|
|
|
|
|
}
|
|
|
|
|
self.taskTipView = nil;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)jumpToTask:(UITapGestureRecognizer *)ges {
|
2024-10-08 11:47:06 +08:00
|
|
|
|
XPWebViewController * webVC =[[XPWebViewController alloc] initWithRoomUID:nil];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
webVC.url = self.taskTipView.url;
|
|
|
|
|
[self.selectedViewController.navigationController pushViewController:webVC animated:YES];
|
|
|
|
|
if (self.taskTipView.superview) {
|
|
|
|
|
[self.taskTipView removeFromSuperview];
|
|
|
|
|
}
|
|
|
|
|
self.taskTipView = nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - XPAnchorCardViewDelegate
|
|
|
|
|
- (void)xPAnchorCardViewEnterRoom:(NSString *)roomUid {
|
|
|
|
|
if (roomUid.length) {
|
|
|
|
|
[self.anchorCardView removeFromSuperview];
|
|
|
|
|
self.anchorCardView = nil;
|
|
|
|
|
self.needShowAnchorCard = NO;
|
|
|
|
|
[XPRoomViewController openRoom:roomUid viewController:self];
|
|
|
|
|
} else {
|
|
|
|
|
[UIView animateWithDuration:0.5 animations:^{
|
|
|
|
|
self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90);
|
|
|
|
|
} completion:^(BOOL finished) {
|
|
|
|
|
[self.anchorCardView removeFromSuperview];
|
|
|
|
|
self.anchorCardView = nil;
|
|
|
|
|
self.needShowAnchorCard = NO;
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)xPAnchorCardViewClickAvatar:(NSString *)uid {
|
|
|
|
|
if (uid.length) {
|
2024-05-22 19:23:54 +08:00
|
|
|
|
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
|
|
|
|
|
userInfoVC.uid = uid.integerValue;
|
|
|
|
|
[self.selectedViewController.navigationController pushViewController:userInfoVC animated:YES];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-05-22 19:23:54 +08:00
|
|
|
|
|
|
|
|
|
[self.anchorCardView removeFromSuperview];
|
|
|
|
|
self.anchorCardView = nil;
|
|
|
|
|
self.needShowAnchorCard = NO;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)handleAnchorCardSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
|
2024-05-15 17:35:51 +08:00
|
|
|
|
if(recognizer.direction == UISwipeGestureRecognizerDirectionUp) {
|
|
|
|
|
[UIView animateWithDuration:0.5 animations:^{
|
|
|
|
|
self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90);
|
|
|
|
|
} completion:^(BOOL finished) {
|
|
|
|
|
[self.anchorCardView removeFromSuperview];
|
|
|
|
|
self.anchorCardView = nil;
|
|
|
|
|
self.needShowAnchorCard = NO;
|
|
|
|
|
}];
|
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
|
- (XPMiniRoomView *)roomMineView {
|
2024-05-15 17:35:51 +08:00
|
|
|
|
if (!_roomMineView) {
|
|
|
|
|
_roomMineView = [[XPMiniRoomView alloc] init];
|
|
|
|
|
_roomMineView.controller = self;
|
|
|
|
|
_roomMineView.hidden = YES;
|
|
|
|
|
}
|
|
|
|
|
return _roomMineView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (XPAnchorCardView *)anchorCardView {
|
|
|
|
|
if (!_anchorCardView) {
|
|
|
|
|
_anchorCardView = [[XPAnchorCardView alloc] init];
|
|
|
|
|
_anchorCardView.delegate = self;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return _anchorCardView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (XPTaskCompleteTipView *)taskTipView {
|
|
|
|
|
if (!_taskTipView) {
|
|
|
|
|
_taskTipView = [[XPTaskCompleteTipView alloc] initWithFrame:CGRectMake(0, KScreenHeight - kSafeAreaBottomHeight-60-20, KScreenWidth, 20)];
|
|
|
|
|
}
|
|
|
|
|
return _taskTipView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|