合并
This commit is contained in:
32
QXLive/Manager/QXHapticManager.h
Normal file
32
QXLive/Manager/QXHapticManager.h
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// QXHapticManager.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/12/5.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXHapticManager : NSObject
|
||||
|
||||
+ (instancetype)shared;
|
||||
|
||||
// 检查是否支持触觉反馈
|
||||
+ (BOOL)isHapticFeedbackSupported;
|
||||
|
||||
// 各种触觉反馈方法
|
||||
- (void)impactWithStyle:(UIImpactFeedbackStyle)style;
|
||||
- (void)impactMedium;
|
||||
- (void)notificationWithType:(UINotificationFeedbackType)type;
|
||||
- (void)selectionChanged;
|
||||
|
||||
// 带准备的触觉反馈
|
||||
- (void)prepareImpactWithStyle:(UIImpactFeedbackStyle)style;
|
||||
- (void)triggerPreparedImpact;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
172
QXLive/Manager/QXHapticManager.m
Normal file
172
QXLive/Manager/QXHapticManager.m
Normal file
@@ -0,0 +1,172 @@
|
||||
//
|
||||
// QXQXQXHapticManager.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/12/5.
|
||||
//
|
||||
|
||||
#import "QXHapticManager.h"
|
||||
#import <sys/utsname.h>
|
||||
@interface QXHapticManager ()
|
||||
@property (nonatomic, strong) UIImpactFeedbackGenerator *impactGenerator;
|
||||
@property (nonatomic, strong) UINotificationFeedbackGenerator *notificationGenerator;
|
||||
@property (nonatomic, strong) UISelectionFeedbackGenerator *selectionGenerator;
|
||||
@property (nonatomic, assign) BOOL isImpactPrepared;
|
||||
@property (nonatomic, assign) UIImpactFeedbackStyle preparedStyle;
|
||||
@end
|
||||
|
||||
@implementation QXHapticManager
|
||||
|
||||
+ (instancetype)shared {
|
||||
static QXHapticManager *instance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
instance = [[QXHapticManager alloc] init];
|
||||
});
|
||||
return instance;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_isImpactPrepared = NO;
|
||||
// 提前初始化所有生成器
|
||||
_impactGenerator = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium];
|
||||
_notificationGenerator = [[UINotificationFeedbackGenerator alloc] init];
|
||||
_selectionGenerator = [[UISelectionFeedbackGenerator alloc] init];
|
||||
|
||||
// 提前准备所有生成器
|
||||
[self prepareAllGenerators];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - 支持性检查
|
||||
+ (BOOL)isHapticFeedbackSupported {
|
||||
if (@available(iOS 10.0, *)) {
|
||||
// 检查设备型号是否支持
|
||||
NSString *deviceModel = [[UIDevice currentDevice] model];
|
||||
|
||||
// 检查是否是iPhone 7及以后
|
||||
// 这里简化检查,实际应使用更精确的设备型号检测
|
||||
// 可以使用 sysctlbyname 获取更精确的设备信息
|
||||
struct utsname systemInfo;
|
||||
uname(&systemInfo);
|
||||
NSString *deviceIdentifier = [NSString stringWithCString:systemInfo.machine
|
||||
encoding:NSUTF8StringEncoding];
|
||||
|
||||
// iPhone 7及以后的设备标识符(部分示例)
|
||||
NSArray *supportedDevices = @[
|
||||
@"iPhone9,", @"iPhone10,", @"iPhone11,", @"iPhone12,",
|
||||
@"iPhone13,", @"iPhone14,", @"iPhone15,", @"iPhone16,",
|
||||
@"iPhone8,4" // iPhone SE (第二代)
|
||||
];
|
||||
|
||||
BOOL isSupportedDevice = NO;
|
||||
for (NSString *prefix in supportedDevices) {
|
||||
if ([deviceIdentifier hasPrefix:prefix]) {
|
||||
isSupportedDevice = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是模拟器,返回YES以支持调试
|
||||
#if TARGET_IPHONE_SIMULATOR
|
||||
return YES;
|
||||
#else
|
||||
return isSupportedDevice;
|
||||
#endif
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)prepareAllGenerators {
|
||||
if (![QXHapticManager isHapticFeedbackSupported]) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 在主线程准备所有生成器
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.impactGenerator prepare];
|
||||
[self.notificationGenerator prepare];
|
||||
[self.selectionGenerator prepare];
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - 即时触觉反馈
|
||||
- (void)impactWithStyle:(UIImpactFeedbackStyle)style {
|
||||
if (![QXHapticManager isHapticFeedbackSupported]) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// 创建新的生成器确保每次都触发
|
||||
UIImpactFeedbackGenerator *generator = [[UIImpactFeedbackGenerator alloc] initWithStyle:style];
|
||||
[generator prepare];
|
||||
[generator impactOccurred];
|
||||
|
||||
// 延迟释放
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[generator prepare];
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
- (void)impactMedium {
|
||||
[self impactWithStyle:UIImpactFeedbackStyleMedium];
|
||||
}
|
||||
|
||||
#pragma mark - 带准备的触觉反馈
|
||||
- (void)prepareImpactWithStyle:(UIImpactFeedbackStyle)style {
|
||||
if (![QXHapticManager isHapticFeedbackSupported]) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.preparedStyle = style;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// 重新创建生成器
|
||||
self.impactGenerator = [[UIImpactFeedbackGenerator alloc] initWithStyle:style];
|
||||
[self.impactGenerator prepare];
|
||||
self.isImpactPrepared = YES;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)triggerPreparedImpact {
|
||||
if (![QXHapticManager isHapticFeedbackSupported] || !self.isImpactPrepared) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.impactGenerator) {
|
||||
[self.impactGenerator impactOccurred];
|
||||
// 准备下一次
|
||||
[self.impactGenerator prepare];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - 其他类型的触觉反馈
|
||||
- (void)notificationWithType:(UINotificationFeedbackType)type {
|
||||
if (![QXHapticManager isHapticFeedbackSupported]) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.notificationGenerator notificationOccurred:type];
|
||||
[self.notificationGenerator prepare];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)selectionChanged {
|
||||
if (![QXHapticManager isHapticFeedbackSupported]) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.selectionGenerator selectionChanged];
|
||||
[self.selectionGenerator prepare];
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -10,6 +10,7 @@
|
||||
#import "QXRoomModel.h"
|
||||
#import "QXRoomFriendRelationModel.h"
|
||||
#import "QXRedPacketModel.h"
|
||||
#import "QXUserSongListModel.h"
|
||||
|
||||
typedef NS_ENUM(NSInteger) {
|
||||
/// 清空消息
|
||||
@@ -20,6 +21,11 @@ typedef NS_ENUM(NSInteger) {
|
||||
QXRoomMessageTypeMuteRemoteAudio = 125,
|
||||
/// 关闭自己声音
|
||||
QXRoomMessageTypeMuteLocalAudio = 126,
|
||||
/// 发送|接收到心动信号
|
||||
QXRoomMessageTypeSendAndRecieveCpHeartSignal = 130,
|
||||
/// cp双向奔赴
|
||||
QXRoomMessageTypeCpHeartFinished = 131,
|
||||
|
||||
/// 基础文本消息类型
|
||||
QXRoomMessageTypeText = 1,
|
||||
/// 基础表情类型
|
||||
@@ -132,6 +138,29 @@ typedef NS_ENUM(NSInteger) {
|
||||
QXRoomMessageTypeSendRedpacket = 1060,
|
||||
/// 红包已被抢完
|
||||
QXRoomMessageTypeRedpacketFinished = 1061,
|
||||
|
||||
/// 点歌房当前歌曲发生变化
|
||||
QXRoomMessageTypeSingerRoomCurrentSongDidChanged = 1070,
|
||||
/// 点歌房下一首歌曲发生变化
|
||||
QXRoomMessageTypeSingerRoomNextSongDidChanged = 1071,
|
||||
/// 歌曲数量发生变化
|
||||
QXRoomMessageTypeSingerRoomSongCountDidChanged = 1072,
|
||||
|
||||
/// CP 特效
|
||||
QXRoomMessageTypeCpJoinRoom = 1080,
|
||||
|
||||
|
||||
/// 开始签约
|
||||
QXRoomMessageTypeStartSign = 1090,
|
||||
/// 结束签约
|
||||
QXRoomMessageTypeEndSign = 1092,
|
||||
/// 签约延时
|
||||
QXRoomMessageTypeDelaySignTime = 1093,
|
||||
/// 身价发生变化
|
||||
QXRoomMessageTypeSignBodyPriceDidChanged = 1091,
|
||||
|
||||
/// 签约麦邀请
|
||||
QXRoomMessageTypeInviteSignUpSeat = 1094,
|
||||
}QXRoomMessageType;
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@protocol QXRoomMessageManagerDelegate <NSObject>
|
||||
@@ -268,22 +297,47 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// 房间用户在线状态发生变化
|
||||
//-(void)roomUserOnlineStatusDidChanged:(BOOL)isOnline userId:(NSString*)userId;
|
||||
|
||||
|
||||
/// 点唱房当前歌曲信息发生变化
|
||||
-(void)singerSongCurrentSongInfoDidChanged:(QXUserSongListModel*)model;
|
||||
/// 点唱房下一首歌信息发生变化
|
||||
-(void)singerSongNextSongInfoDidChanged:(QXUserSongListModel*)model;
|
||||
/// 已点歌曲数量发生变化
|
||||
-(void)singerSongCountDidChanged:(NSString*)count;
|
||||
|
||||
|
||||
/// 签约开始
|
||||
-(void)signDidStartWithEndTime:(NSString *)endTime signId:(NSString *)signId signDay:(NSString*)signDay signValue:(NSString*)signValue;
|
||||
/// 签约结束
|
||||
-(void)signDidEndWithUserInfo1:(QXUserHomeModel*)userInfo1 userInfo2:(QXUserHomeModel*)userInfo2 sign_value:(NSString*)sign_value;
|
||||
/// 签约身价变化
|
||||
-(void)signValueDidChangedWithSignUserInfo:(QXUserHomeModel*)signUserInfo sign_value:(NSString*)sign_value signId:(NSString*)signId sign_coin_list:(NSArray*)sign_coin_list;
|
||||
/// 签约身价变化
|
||||
-(void)signTimeDelayWithEndTime:(NSString*)endTime;
|
||||
/// 主持邀请上签约麦
|
||||
-(void)signSeatInviteWithUserId:(NSString*)userId content:(NSString*)content;
|
||||
|
||||
@end
|
||||
@interface QXRoomMessageManager : NSObject
|
||||
@property (nonatomic,weak)id<QXRoomMessageManagerDelegate>delegate;
|
||||
|
||||
+(instancetype)shared;
|
||||
|
||||
-(void)addC2CObserver;
|
||||
/// 加入房间群组
|
||||
-(void)joinGroupWithRoomId:(NSString*)roomId;
|
||||
|
||||
/// 退出房间群组
|
||||
-(void)quitGroupWithRoomId:(NSString*)roomId;
|
||||
-(void)quitGroupWithRoomId:(NSString*)roomId removeListener:(BOOL)removeListener;
|
||||
|
||||
-(void)sendChatMessage:(NSString *)message messageType:(QXRoomMessageType)messageType needInsertMessage:(BOOL)needInsertMessage;
|
||||
/// 发送表情
|
||||
-(void)sendChatEmoji:(QXEmojiModel *)emoji;
|
||||
|
||||
-(void)sendC2CMessage:(NSString *)message messageType:(QXRoomMessageType)messageType userId:(NSString*)userId;
|
||||
|
||||
-(void)showCpFinishedAlertViewWithText:(NSString*)text;
|
||||
@end
|
||||
|
||||
@interface QXRoomMessage : NSObject
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
#import "QXGiftDisplayManager.h"
|
||||
#import <AgoraRtcKit/AgoraRtcEngineKit.h>
|
||||
#import "TUIChatConfig.h"
|
||||
#import "QXDrifNobilityJoinRoomView.h"
|
||||
#import "QXCustomAlertView.h"
|
||||
#import "QXHeartBeatSpaceViewController.h"
|
||||
|
||||
@interface QXRoomMessageManager() <V2TIMGroupListener,V2TIMSimpleMsgListener,V2TIMAdvancedMsgListener>
|
||||
@property (nonatomic,strong)NSString *groupId;
|
||||
@@ -33,13 +36,15 @@
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)addC2CObserver{
|
||||
[[V2TIMManager sharedInstance] addSimpleMsgListener:self];
|
||||
}
|
||||
-(void)joinGroupWithRoomId:(NSString *)roomId{
|
||||
MJWeakSelf
|
||||
if (self.groupId) {
|
||||
[self quitGroupWithRoomId:self.groupId];
|
||||
[self quitGroupWithRoomId:self.groupId removeListener:YES];
|
||||
}
|
||||
[[V2TIMManager sharedInstance] addGroupListener:self];
|
||||
[[V2TIMManager sharedInstance] addSimpleMsgListener:self];
|
||||
[[V2TIMManager sharedInstance] addAdvancedMsgListener:self];
|
||||
NSString *groupId = [NSString stringWithFormat:@"room%@",roomId];
|
||||
[[V2TIMManager sharedInstance] joinGroup:groupId msg:@"大家好,我来啦" succ:^{
|
||||
@@ -51,13 +56,13 @@
|
||||
QXLOG(@"腾讯IM加入聊天室失败-code%d-原因%@",code,desc);
|
||||
}];
|
||||
}
|
||||
-(void)quitGroupWithRoomId:(NSString *)roomId{
|
||||
MJWeakSelf
|
||||
self.groupId = nil;
|
||||
self.roomId = nil;
|
||||
[[V2TIMManager sharedInstance] removeGroupListener:self];
|
||||
[[V2TIMManager sharedInstance] removeSimpleMsgListener:self];
|
||||
[[V2TIMManager sharedInstance] removeAdvancedMsgListener:self];
|
||||
-(void)quitGroupWithRoomId:(NSString *)roomId removeListener:(BOOL)removeListener{
|
||||
if (removeListener) {
|
||||
self.groupId = nil;
|
||||
self.roomId = nil;
|
||||
[[V2TIMManager sharedInstance] removeGroupListener:self];
|
||||
[[V2TIMManager sharedInstance] removeAdvancedMsgListener:self];
|
||||
}
|
||||
NSString *groupId = [NSString stringWithFormat:@"room%@",roomId];
|
||||
[[V2TIMManager sharedInstance] quitGroup:groupId succ:^{
|
||||
|
||||
@@ -109,6 +114,9 @@
|
||||
// md.play_image = jia_jia;
|
||||
[[QXGiftPlayerManager shareManager] displayChatEffectView:jia_jia];
|
||||
}
|
||||
if ([model.FromUserInfo.enter_image isExist]) {
|
||||
[[QXDrifNobilityJoinRoomView shareView] addNobilityUserModel:model];
|
||||
}
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
@@ -624,13 +632,13 @@
|
||||
// 1 在线 2离线
|
||||
NSInteger type = 1;
|
||||
type = [msg.Text[@"type"] integerValue];
|
||||
BOOL isOnline = type == 1?YES:NO;
|
||||
// BOOL isOnline = type == 1?YES:NO;
|
||||
// if (self.delegate && [self.delegate respondsToSelector:@selector(roomUserOnlineStatusDidChanged:userId:)]) {
|
||||
// [self.delegate roomUserOnlineStatusDidChanged:YES userId:userId];
|
||||
// }
|
||||
NSDictionary *parm = @{
|
||||
@"user_id":userId,
|
||||
@"is_online":[NSNumber numberWithBool:isOnline],
|
||||
@"is_online":[NSNumber numberWithInteger:type],
|
||||
};
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:noticeRoomUserOnlineStatusDidChanged object:parm];
|
||||
}
|
||||
@@ -649,6 +657,80 @@
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case QXRoomMessageTypeSingerRoomCurrentSongDidChanged:{
|
||||
QXUserSongListModel *songInfo = [QXUserSongListModel yy_modelWithJSON:msg.Text[@"song_info"]];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(singerSongCurrentSongInfoDidChanged:)]) {
|
||||
[self.delegate singerSongCurrentSongInfoDidChanged:songInfo];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QXRoomMessageTypeSingerRoomNextSongDidChanged:{
|
||||
QXUserSongListModel *songInfo = [QXUserSongListModel yy_modelWithJSON:msg.Text[@"next_song_info"]];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(singerSongNextSongInfoDidChanged:)]) {
|
||||
[self.delegate singerSongNextSongInfoDidChanged:songInfo];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QXRoomMessageTypeSingerRoomSongCountDidChanged:{
|
||||
NSString *songCount = [NSString stringWithFormat:@"%@",msg.Text[@"count"]];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(singerSongCountDidChanged:)]) {
|
||||
[self.delegate singerSongCountDidChanged:songCount];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QXRoomMessageTypeCpJoinRoom:{
|
||||
QXRoomChatListModel *model = [QXRoomChatListModel yy_modelWithJSON:msg.Text];
|
||||
[[QXGiftPlayerManager shareManager] displayCpEffectView:model];
|
||||
}
|
||||
break;
|
||||
case QXRoomMessageTypeStartSign:{
|
||||
NSString *sign_id = [NSString stringWithFormat:@"%@",msg.Text[@"sign_id"]];
|
||||
NSString *end_time = [NSString stringWithFormat:@"%@",msg.Text[@"end_time"]];
|
||||
NSString *sign_day = [NSString stringWithFormat:@"%@",msg.Text[@"sign_day"]];
|
||||
NSString *current_body_value = [NSString stringWithFormat:@"%@",msg.Text[@"current_body_value"]];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(signDidStartWithEndTime:signId:signDay:signValue:)]) {
|
||||
[self.delegate signDidStartWithEndTime:end_time signId:sign_id signDay:sign_day signValue:current_body_value];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QXRoomMessageTypeEndSign:{
|
||||
QXRoomChatListModel *model = [QXRoomChatListModel yy_modelWithJSON:msg.Text];
|
||||
NSString *sign_value = [NSString stringWithFormat:@"%@",msg.Text[@"sign_value"]];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(signDidEndWithUserInfo1:userInfo2:sign_value:)]) {
|
||||
[self.delegate signDidEndWithUserInfo1:model.FromUserInfo userInfo2:model.ToUserInfo sign_value:sign_value];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QXRoomMessageTypeDelaySignTime:{
|
||||
NSString *end_time = [NSString stringWithFormat:@"%@",msg.Text[@"end_time"]];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(signTimeDelayWithEndTime:)]) {
|
||||
[self.delegate signTimeDelayWithEndTime:end_time];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QXRoomMessageTypeSignBodyPriceDidChanged:{
|
||||
QXRoomChatListModel *model = [QXRoomChatListModel yy_modelWithJSON:msg.Text];
|
||||
NSString *sign_id = [NSString stringWithFormat:@"%@",msg.Text[@"sign_id"]];
|
||||
NSString *sign_value = [NSString stringWithFormat:@"%@",msg.Text[@"sign_value"]];
|
||||
NSArray *sign_coin_list;
|
||||
id object = msg.Text[@"sign_coin_list"];
|
||||
if ([object isKindOfClass:[NSArray class]]) {
|
||||
sign_coin_list = object;
|
||||
}
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(signValueDidChangedWithSignUserInfo:sign_value:signId:sign_coin_list:)]) {
|
||||
[self.delegate signValueDidChangedWithSignUserInfo:model.FromUserInfo sign_value:sign_value signId:sign_id sign_coin_list:sign_coin_list];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QXRoomMessageTypeInviteSignUpSeat:{
|
||||
NSString *user_id = [NSString stringWithFormat:@"%@",msg.Text[@"user_id"]];
|
||||
NSString *text = [NSString stringWithFormat:@"%@",msg.Text[@"text"]];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(signSeatInviteWithUserId:content:)]) {
|
||||
[self.delegate signSeatInviteWithUserId:user_id content:text];
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -668,6 +750,46 @@
|
||||
|
||||
*/
|
||||
|
||||
-(void)reSendGiftWithId:(NSString*)giftId userId:(NSString*)userId{
|
||||
MJWeakSelf
|
||||
[QXMineNetwork userCpReSendWithGiftId:giftId userId:userId roomId:self.roomId successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
|
||||
id object = dict[@"cp_type"];
|
||||
if ([object isKindOfClass:[NSDictionary class]]) {
|
||||
NSDictionary *cpDict = (NSDictionary *)object;
|
||||
NSString *cp_type = object[@"cp_type"];
|
||||
if (cp_type.intValue == 1) {
|
||||
/// 单向送cp礼物
|
||||
NSString *jsonStr = [cpDict jsonStringEncoded];
|
||||
[[QXRoomMessageManager shared] sendC2CMessage:jsonStr messageType:(QXRoomMessageTypeSendAndRecieveCpHeartSignal) userId:userId];
|
||||
}else if (cp_type.intValue == 2){
|
||||
/// cp礼物已达成双向绑定
|
||||
NSString *jsonStr = [cpDict jsonStringEncoded];
|
||||
[[QXRoomMessageManager shared] sendC2CMessage:jsonStr messageType:(QXRoomMessageTypeCpHeartFinished) userId:userId];
|
||||
NSString *message = [NSString stringWithFormat:@"%@",cpDict[@"text"]];
|
||||
[weakSelf showCpFinishedAlertViewWithText:message];
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
showToast(msg);
|
||||
}];
|
||||
}
|
||||
-(void)showCpFinishedAlertViewWithText:(NSString*)text{
|
||||
QXCustomAlertView *alertView = [[QXCustomAlertView alloc] init];
|
||||
|
||||
[alertView showInView:KEYWINDOW title:@"缘定三生 此刻同心" message:text cancleTitle:@"稍后进入" commitTitle:@"进入心动空间"];
|
||||
|
||||
alertView.commitBlock = ^{
|
||||
QXLOG(@"进入心动空间");
|
||||
QXHeartBeatSpaceViewController *vc = [[QXHeartBeatSpaceViewController alloc] init];
|
||||
QXRoomNavigationController *navagationController = (QXRoomNavigationController*)KEYWINDOW.rootViewController;
|
||||
vc.userId = QXGlobal.shareGlobal.loginModel.user_id;
|
||||
[navagationController pushViewController:vc animated:YES];
|
||||
};
|
||||
}
|
||||
|
||||
-(void)onRecvC2CTextMessage:(NSString *)msgID sender:(V2TIMUserInfo *)info text:(NSString *)text{
|
||||
|
||||
@@ -684,6 +806,23 @@
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(pkMuteRemoteAudio:fromUserInfo:)]) {
|
||||
[self.delegate pkMuteRemoteAudio:is_mute==1 fromUserInfo:model.FromUserInfo];
|
||||
}
|
||||
}else if (meesageType == QXRoomMessageTypeSendAndRecieveCpHeartSignal){
|
||||
NSString *json = [NSString stringWithFormat:@"%@",msg.Text[@"text"]];
|
||||
NSDictionary *dict = [json jsonValueDecoded];
|
||||
NSString *message = [NSString stringWithFormat:@"%@",dict[@"text1"]];
|
||||
__block NSString *gift_id = [NSString stringWithFormat:@"%@",dict[@"gift_id"]];
|
||||
QXRoomChatListModel *model = [QXRoomChatListModel yy_modelWithJSON:msg.Text];
|
||||
QXCustomAlertView *alertView = [[QXCustomAlertView alloc] init];
|
||||
[alertView showInView:KEYWINDOW title:@"心动信号" message:message cancleTitle:@"再想想" commitTitle:@"回赠"];
|
||||
MJWeakSelf
|
||||
alertView.commitBlock = ^{
|
||||
[weakSelf reSendGiftWithId:gift_id userId:model.FromUserInfo.user_id];
|
||||
};
|
||||
}else if (meesageType == QXRoomMessageTypeCpHeartFinished){
|
||||
NSString *json = [NSString stringWithFormat:@"%@",msg.Text[@"text"]];
|
||||
NSDictionary *dict = [json jsonValueDecoded];
|
||||
NSString *message = [NSString stringWithFormat:@"%@",dict[@"text1"]];
|
||||
[self showCpFinishedAlertViewWithText:message];
|
||||
}
|
||||
}
|
||||
-(void)onRecvGroupCustomMessage:(NSString *)msgID groupID:(NSString *)groupID sender:(V2TIMGroupMemberInfo *)info customData:(NSData *)data{
|
||||
@@ -715,7 +854,7 @@
|
||||
}else if (meesageType == QXRoomMessageTypeMuteLocalAudio){
|
||||
NSString *json = [NSString stringWithFormat:@"%@",msg.Text[@"text"]];
|
||||
NSDictionary *dict = [json jsonValueDecoded];
|
||||
NSInteger is_mute = [[dict objectForKey:@"is_mute"] integerValue];
|
||||
// NSInteger is_mute = [[dict objectForKey:@"is_mute"] integerValue];
|
||||
QXUserHomeModel *userModel = [QXUserHomeModel yy_modelWithJSON:msg.Text[@"FromUserInfo"]];
|
||||
AgoraRtcAudioVolumeInfo *userInfo = [[AgoraRtcAudioVolumeInfo alloc] init];
|
||||
userInfo.uid = userModel.user_id.longLongValue;
|
||||
@@ -743,6 +882,8 @@
|
||||
@"avatar":[QXGlobal shareGlobal].loginModel.avatar?[QXGlobal shareGlobal].loginModel.avatar:@"",
|
||||
@"icon":[QXGlobal shareGlobal].loginModel.icon?[QXGlobal shareGlobal].loginModel.icon:@"",
|
||||
@"chat_bubble":[QXGlobal shareGlobal].loginModel.chat_bubble?:@"",
|
||||
@"nobility_image":[QXGlobal shareGlobal].loginModel.nobility_image?:@"",
|
||||
@"nickname_color":[QXGlobal shareGlobal].loginModel.nickname_color?:@"",
|
||||
},
|
||||
@"text":message
|
||||
}
|
||||
@@ -756,6 +897,8 @@
|
||||
userInfo.user_id = [QXGlobal shareGlobal].loginModel.user_id;
|
||||
userInfo.icon = [QXGlobal shareGlobal].loginModel.icon;
|
||||
userInfo.chat_bubble = [QXGlobal shareGlobal].loginModel.chat_bubble;
|
||||
userInfo.nobility_image = [QXGlobal shareGlobal].loginModel.nobility_image;
|
||||
userInfo.nickname_color = [QXGlobal shareGlobal].loginModel.nickname_color;
|
||||
model.FromUserInfo = userInfo;
|
||||
model.messageType = QXRoomChatMessageTypeChat;
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
@@ -783,6 +926,8 @@
|
||||
@"avatar":[QXGlobal shareGlobal].loginModel.avatar?[QXGlobal shareGlobal].loginModel.avatar:@"",
|
||||
@"icon":[QXGlobal shareGlobal].loginModel.icon?[QXGlobal shareGlobal].loginModel.icon:@"",
|
||||
@"chat_bubble":[QXGlobal shareGlobal].loginModel.chat_bubble?:@"",
|
||||
@"nobility_image":[QXGlobal shareGlobal].loginModel.nobility_image?:@"",
|
||||
@"nickname_color":[QXGlobal shareGlobal].loginModel.nickname_color?:@"",
|
||||
},
|
||||
@"emoji":@{
|
||||
@"image":emoji.image?:@"",
|
||||
@@ -799,6 +944,8 @@
|
||||
userInfo.user_id = [QXGlobal shareGlobal].loginModel.user_id;
|
||||
userInfo.icon = [QXGlobal shareGlobal].loginModel.icon;
|
||||
userInfo.chat_bubble = [QXGlobal shareGlobal].loginModel.chat_bubble;
|
||||
userInfo.nobility_image = [QXGlobal shareGlobal].loginModel.nobility_image;
|
||||
userInfo.nickname_color = [QXGlobal shareGlobal].loginModel.nickname_color;
|
||||
model.FromUserInfo = userInfo;
|
||||
model.messageType = QXRoomChatMessageTypeEmoji;
|
||||
model.emoji = emoji;
|
||||
@@ -843,9 +990,9 @@
|
||||
[[V2TIMManager sharedInstance] sendMessage:message1 receiver:toUserId groupID:nil priority:(V2TIM_PRIORITY_HIGH) onlineUserOnly:YES offlinePushInfo:nil progress:^(uint32_t progress) {
|
||||
|
||||
} succ:^{
|
||||
|
||||
QXLOG(@"c2c发送成功");
|
||||
} fail:^(int code, NSString * _Nullable desc) {
|
||||
|
||||
QXLOG(@"c2c发送失败");
|
||||
}];
|
||||
}
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user