|
9 | 9 | #import "RNNotificationCenter.h" |
10 | 10 | #import <AVFoundation/AVFoundation.h> |
11 | 11 | #import "NSDictionary+NTESJson.h" |
| 12 | +#import "NIMMessageMaker.h" |
12 | 13 | @interface RNNotificationCenter () <NIMSystemNotificationManagerDelegate,NIMChatManagerDelegate> |
13 | 14 | @property (nonatomic,strong) AVAudioPlayer *player; //播放提示音 |
14 | 15 | @end |
@@ -84,15 +85,39 @@ - (void)checkMessageAt:(NSArray *)messages |
84 | 85 |
|
85 | 86 | #pragma mark - NIMSystemNotificationManagerDelegate |
86 | 87 | - (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification{//接收自定义通知 |
87 | | - |
88 | | - NSString *content = notification.content; |
| 88 | +// NSString *content = notification.content; |
89 | 89 | NSDictionary *notiDict = notification.apnsPayload; |
90 | 90 | if (notiDict){ |
91 | | - if ([[notiDict objectForKey:@"type"] integerValue]==1) {//加好友 |
92 | | - |
| 91 | + NSInteger notiType = [[notiDict objectForKey:@"type"] integerValue]; |
| 92 | + switch (notiType) { |
| 93 | + case 1://加好友 |
| 94 | + |
| 95 | + break; |
| 96 | + case 2://拆红包消息 |
| 97 | + { |
| 98 | + [self saveTheRedPacketOpenMsg:[notiDict objectForKey:@"data"]]; |
| 99 | + } |
| 100 | + break; |
| 101 | + |
| 102 | + default: |
| 103 | + break; |
93 | 104 | } |
94 | 105 | } |
95 | 106 | } |
96 | | - |
| 107 | +//保存拆红包消息到本地 |
| 108 | +- (void)saveTheRedPacketOpenMsg:(NSDictionary *)dict{ |
| 109 | + NSDictionary *datatDict = [dict objectForKey:@"dict"]; |
| 110 | + NSTimeInterval timestamp = [[dict objectForKey:@"timestamp"] doubleValue]; |
| 111 | + NSString *sessionId = [dict objectForKey:@"sessionId"]; |
| 112 | + NSInteger sessionType = [[dict objectForKey:@"sessionType"] integerValue]; |
| 113 | + NIMSession *session = [NIMSession session:sessionId type:sessionType]; |
| 114 | + NIMMessage *message; |
| 115 | + DWCustomAttachment *obj = [[DWCustomAttachment alloc]init]; |
| 116 | + obj.custType = CustomMessgeTypeRedPacketOpenMessage; |
| 117 | + obj.dataDict = datatDict; |
| 118 | + message = [NIMMessageMaker msgWithCustomAttachment:obj]; |
| 119 | + message.timestamp = timestamp; |
| 120 | + [[NIMSDK sharedSDK].conversationManager saveMessage:message forSession:session completion:nil]; |
| 121 | +} |
97 | 122 |
|
98 | 123 | @end |
0 commit comments