// // YOUPAIBBCustomSystomNotification.m // VQU // // Created by Elaine on 2021/10/28. // Copyright © 2021 MS. All rights reserved. // #import "YOUPAIBBCustomSystomNotification.h" @implementation YOUPAIBBCustomSystomNotification +(void)youpaifcustomSystomNotificationWithModel:(YOUPAILCVideoChatModel *)videoModel type:(BBCustomSystomNotificationType)type block:(nonnull void (^)(NSError * _Nonnull error))block{ NSString *uid = videoModel.youpaipfrom_uid; if (type == BBCustomSystomNotificationTypeWithCallVideo || type == BBCustomSystomNotificationTypeWithCancelVideo) { uid = videoModel.youpaipto_uid; } if (type == BBCustomSystomNotificationTypeWithHangupCallVideo) { uid = [videoModel.youpaipto_uid isEqual:[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id] ? videoModel.youpaipfrom_uid : videoModel.youpaipto_uid; } NSDictionary* dictData = @{@"id":@(type), @"data": @{ @"room_id":videoModel.youpaiproom_id, @"auditState":@(videoModel.youpaipauditState), @"from_uid":videoModel.youpaipfrom_uid, @"from_nickname":videoModel.youpaipfrom_nickname, @"from_avatar":videoModel.youpaipfrom_avatar, @"to_uid":videoModel.youpaipto_uid, @"to_nickname":videoModel.youpaipto_nickname, @"to_avatar":videoModel.youpaipto_avatar, @"callTime":[LCTools getCurrentTimestamp] } }; NSString* str = [dictData mj_JSONString]; NIMCustomSystemNotificationSetting *set = [[NIMCustomSystemNotificationSetting alloc]init]; set.shouldBeCounted = NO; NIMCustomSystemNotification* customSysNotification = [[NIMCustomSystemNotification alloc]initWithContent:str]; customSysNotification.apnsPayload = @{ @"sound":@"open.wav", @"callType":@"video" }; customSysNotification.apnsContent = [self youpaifnotificationTitleWithType:type]; customSysNotification.sendToOnlineUsersOnly = NO; customSysNotification.setting = set; [[NIMSDK sharedSDK].systemNotificationManager sendCustomNotification:customSysNotification toSession:[NIMSession session:uid type:(NIMSessionTypeP2P)] completion:block]; } + (NSString *)youpaifnotificationTitleWithType:(BBCustomSystomNotificationType)type{ NSString *title = @""; switch (type) { case BBCustomSystomNotificationTypeWithCallVideo: title = @"收到视频请求"; break; case BBCustomSystomNotificationTypeWithCancelVideo: title = @"对方已取消"; break; case BBCustomSystomNotificationTypeWithRefuseCallVideo: title = @"对方已拒绝"; break; case BBCustomSystomNotificationTypeWithAnswerCallVideo: title = @"对方已接听"; break; case BBCustomSystomNotificationTypeWithWasInterruptedCallVideo: title = @"视频被中断了"; break; case BBCustomSystomNotificationTypeWithHangupCallVideo: title = @"对方已挂断"; break; default: break; } return title; } @end