YOUPAIBBCustomSystomNotification.m 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // YOUPAIBBCustomSystomNotification.m
  3. // VQU
  4. //
  5. // Created by Elaine on 2021/10/28.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIBBCustomSystomNotification.h"
  9. @implementation YOUPAIBBCustomSystomNotification
  10. +(void)youpaifcustomSystomNotificationWithModel:(YOUPAILCVideoChatModel *)videoModel type:(BBCustomSystomNotificationType)type block:(nonnull void (^)(NSError * _Nonnull error))block{
  11. NSString *uid = videoModel.youpaipfrom_uid;
  12. if (type == BBCustomSystomNotificationTypeWithCallVideo || type == BBCustomSystomNotificationTypeWithCancelVideo) {
  13. uid = videoModel.youpaipto_uid;
  14. }
  15. if (type == BBCustomSystomNotificationTypeWithHangupCallVideo) {
  16. uid = [videoModel.youpaipto_uid isEqual:[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id] ? videoModel.youpaipfrom_uid : videoModel.youpaipto_uid;
  17. }
  18. NSDictionary* dictData = @{@"id":@(type),
  19. @"data": @{
  20. @"room_id":videoModel.youpaiproom_id,
  21. @"auditState":@(videoModel.youpaipauditState),
  22. @"from_uid":videoModel.youpaipfrom_uid,
  23. @"from_nickname":videoModel.youpaipfrom_nickname,
  24. @"from_avatar":videoModel.youpaipfrom_avatar,
  25. @"to_uid":videoModel.youpaipto_uid,
  26. @"to_nickname":videoModel.youpaipto_nickname,
  27. @"to_avatar":videoModel.youpaipto_avatar,
  28. @"callTime":[LCTools getCurrentTimestamp]
  29. }
  30. };
  31. NSString* str = [dictData mj_JSONString];
  32. NIMCustomSystemNotificationSetting *set = [[NIMCustomSystemNotificationSetting alloc]init];
  33. set.shouldBeCounted = NO;
  34. NIMCustomSystemNotification* customSysNotification = [[NIMCustomSystemNotification alloc]initWithContent:str];
  35. customSysNotification.apnsPayload = @{
  36. @"sound":@"open.wav",
  37. @"callType":@"video"
  38. };
  39. customSysNotification.apnsContent = [self youpaifnotificationTitleWithType:type];
  40. customSysNotification.sendToOnlineUsersOnly = NO;
  41. customSysNotification.setting = set;
  42. [[NIMSDK sharedSDK].systemNotificationManager sendCustomNotification:customSysNotification toSession:[NIMSession session:uid type:(NIMSessionTypeP2P)] completion:block];
  43. }
  44. + (NSString *)youpaifnotificationTitleWithType:(BBCustomSystomNotificationType)type{
  45. NSString *title = @"";
  46. switch (type) {
  47. case BBCustomSystomNotificationTypeWithCallVideo:
  48. title = @"收到视频请求";
  49. break;
  50. case BBCustomSystomNotificationTypeWithCancelVideo:
  51. title = @"对方已取消";
  52. break;
  53. case BBCustomSystomNotificationTypeWithRefuseCallVideo:
  54. title = @"对方已拒绝";
  55. break;
  56. case BBCustomSystomNotificationTypeWithAnswerCallVideo:
  57. title = @"对方已接听";
  58. break;
  59. case BBCustomSystomNotificationTypeWithWasInterruptedCallVideo:
  60. title = @"视频被中断了";
  61. break;
  62. case BBCustomSystomNotificationTypeWithHangupCallVideo:
  63. title = @"对方已挂断";
  64. break;
  65. default:
  66. break;
  67. }
  68. return title;
  69. }
  70. @end