@@ -2714,4 +2714,69 @@ - (JMSGOptionalContent *)convertDicToJMSGOptionalContent:(NSDictionary *)dic {
27142714 }];
27152715 }];
27162716}
2717+
2718+
2719+ RCT_EXPORT_METHOD (setConversationExtras:(NSDictionary *)param
2720+ successCallback:(RCTResponseSenderBlock)successCallback
2721+ failCallBack:(RCTResponseSenderBlock)failCallback) {
2722+
2723+ if (!param[@" type" ]) {
2724+ failCallback (@[[self getParamError ]]);
2725+ return ;
2726+ }
2727+
2728+ if (!param[@" extras" ]) {
2729+ failCallback (@[[self getParamError ]]);
2730+ return ;
2731+ }
2732+
2733+ if ([param[@" type" ] isEqual: @" single" ] && param[@" username" ] != nil ) {
2734+
2735+ } else {
2736+ if ([param[@" type" ] isEqual: @" group" ] && param[@" groupId" ] != nil ) {
2737+
2738+ } else {
2739+ failCallback (@[[self getParamError ]]);
2740+ return ;
2741+ }
2742+ }
2743+
2744+ NSString *appKey = nil ;
2745+ if (param[@" appKey" ]) {
2746+ appKey = param[@" appKey" ];
2747+ } else {
2748+ appKey = [JMessageHelper shareInstance ].JMessageAppKey ;
2749+ }
2750+
2751+ if ([param[@" type" ] isEqualToString: @" single" ]) {
2752+ [JMSGConversation createSingleConversationWithUsername: param[@" username" ]
2753+ appKey: appKey
2754+ completionHandler: ^(id resultObject, NSError *error) {
2755+ if (error) {
2756+ failCallback (@[[error errorToDictionary ]]);
2757+ return ;
2758+ }
2759+ JMSGConversation *conversation = resultObject;
2760+ NSDictionary *extras = param[@" extras" ];
2761+ for (NSString *key in extras) {
2762+ [conversation setExtraValue: extras[key] forKey: key];
2763+ }
2764+ successCallback (@[[conversation conversationToDictionary ]]);
2765+ }];
2766+ } else {
2767+ [JMSGConversation createGroupConversationWithGroupId: param[@" groupId" ] completionHandler: ^(id resultObject, NSError *error) {
2768+ if (error) {
2769+ failCallback (@[[error errorToDictionary ]]);
2770+ return ;
2771+ }
2772+ JMSGConversation *conversation = resultObject;
2773+ NSDictionary *extras = param[@" extras" ];
2774+ for (NSString *key in extras) {
2775+ [conversation setExtraValue: extras[key] forKey: key];
2776+ }
2777+ successCallback (@[[conversation conversationToDictionary ]]);
2778+ }];
2779+ }
2780+ }
2781+
27172782@end
0 commit comments