@@ -176,54 +176,29 @@ -(void)didSendMessage:(NSNotification *)notification {
176176// }
177177
178178- (void )loginStateChanged : (NSNotification *)notification {
179- // CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{@"eventName": @"loginStateChanged", @"value": notification.object}];
180- //
181- // [result setKeepCallback:@(true)];
182- // [self.commandDelegate sendPluginResult:result callbackId:self.callBack.callbackId];
183-
179+
184180 [self .bridge.eventDispatcher sendAppEventWithName: loginStateChangedEvent body: notification.object];
185181}
186182
187183- (void )onContactNotify : (NSNotification *)notification {
188- // CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{@"eventName": @"contactNotify", @"value": notification.object}];
189- //
190- // [result setKeepCallback:@(true)];
191- // [self.commandDelegate sendPluginResult:result callbackId:self.callBack.callbackId];
192-
184+
193185 [self .bridge.eventDispatcher sendAppEventWithName: contactNotifyEvent body: notification.object];
194186}
195187
196188- (void )didReceiveRetractMessage : (NSNotification *)notification {
197- // CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{@"eventName": @"retractMessage", @"value": notification.object}];
198- //
199- // [result setKeepCallback:@(true)];
200- // [self.commandDelegate sendPluginResult:result callbackId:self.callBack.callbackId];
189+
201190 [self .bridge.eventDispatcher sendAppEventWithName: messageRetractEvent body: notification.object];
202191}
203192
204193// didReceiveJMessageMessage change name
205194- (void )didReceiveJMessageMessage : (NSNotification *)notification {
206- // CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{@"eventName": @"receiveMessage", @"value": notification.object}];
207- // [result setKeepCallback:@(true)];
208- //
209- // [self.commandDelegate sendPluginResult:result callbackId:self.callBack.callbackId];
195+
210196 [self .bridge.eventDispatcher sendAppEventWithName: receiveMsgEvent body: notification.object];
211197}
212198
213199// TODO: fix <================
214200
215201
216- // +(void)evalFuntionName:(NSString*)functionName jsonParm:(NSString*)jsonString{
217- // dispatch_async(dispatch_get_main_queue(), ^{
218- // [SharedJMessagePlugin.commandDelegate evalJs:[NSString stringWithFormat:@"%@.%@('%@')",JMessagePluginName,functionName,jsonString]];
219- // });
220- // }
221- //
222- // +(void)fireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString{
223- // dispatch_async(dispatch_get_main_queue(), ^{
224- // [SharedJMessagePlugin.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jmessage.%@',%@)", eventName, jsString]];
225- // });
226- // }
227202
228203// #pragma mark IM - User
229204
@@ -298,7 +273,6 @@ - (void)didReceiveJMessageMessage:(NSNotification *)notification {
298273RCT_EXPORT_METHOD (updateMyPassword:(NSDictionary *)param
299274 successCallback:(RCTResponseSenderBlock)successCallback
300275 failCallback:(RCTResponseSenderBlock)failCallback) {
301- // NSDictionary * param = [command argumentAtIndex:0];
302276
303277 if (param[@" oldPwd" ] && param[@" newPwd" ]) {
304278 [JMSGUser updateMyPasswordWithNewPassword: param[@" newPwd" ] oldPassword: param[@" oldPwd" ] completionHandler: ^(id resultObject, NSError *error) {
@@ -317,7 +291,6 @@ - (void)didReceiveJMessageMessage:(NSNotification *)notification {
317291RCT_EXPORT_METHOD (updateMyAvatar:(NSDictionary *)param
318292 successCallback:(RCTResponseSenderBlock)successCallback
319293 failCallback:(RCTResponseSenderBlock)failCallback) {
320- // NSDictionary * param = [command argumentAtIndex:0];
321294
322295 if (!param[@" imgPath" ]) {
323296 failCallback (@[[self getParamError ]]);
@@ -428,7 +401,6 @@ - (JMSGOptionalContent *)convertDicToJMSGOptionalContent:(NSDictionary *)dic {
428401RCT_EXPORT_METHOD (sendTextMessage:(NSDictionary *)param
429402 successCallback:(RCTResponseSenderBlock)successCallback
430403 failCallback:(RCTResponseSenderBlock)failCallback) {
431- // NSDictionary * param = [command argumentAtIndex:0];
432404
433405 if (param[@" type" ] == nil ) {
434406
@@ -504,7 +476,6 @@ - (JMSGOptionalContent *)convertDicToJMSGOptionalContent:(NSDictionary *)dic {
504476RCT_EXPORT_METHOD (sendImageMessage:(NSDictionary *)param
505477 successCallback:(RCTResponseSenderBlock)successCallback
506478 failCallback:(RCTResponseSenderBlock)failCallback) {
507- // NSDictionary * param = [command argumentAtIndex:0];
508479
509480 if (param[@" type" ] == nil ) {
510481 failCallback (@[[self getParamError ]]);
@@ -891,7 +862,7 @@ - (JMSGOptionalContent *)convertDicToJMSGOptionalContent:(NSDictionary *)dic {
891862RCT_EXPORT_METHOD (getHistoryMessages:(NSDictionary *)param
892863 successCallback:(RCTResponseSenderBlock)successCallback
893864 failCallback:(RCTResponseSenderBlock)failCallback) {
894- // NSDictionary * param = [command argumentAtIndex:0];
865+
895866 if (param[@" type" ] == nil ||
896867 param[@" from" ] == nil ||
897868 param[@" limit" ] == nil ) {
@@ -978,7 +949,7 @@ - (JMSGOptionalContent *)convertDicToJMSGOptionalContent:(NSDictionary *)dic {
978949RCT_EXPORT_METHOD (acceptInvitation:(NSDictionary *)param
979950 successCallback:(RCTResponseSenderBlock)successCallback
980951 failCallback:(RCTResponseSenderBlock)failCallback) {
981- // NSDictionary * param = [command argumentAtIndex:0];
952+
982953 if (param[@" username" ] == nil ) {
983954 failCallback (@[[self getParamError ]]);
984955 return ;
@@ -2185,5 +2156,27 @@ - (JMSGOptionalContent *)convertDicToJMSGOptionalContent:(NSDictionary *)dic {
21852156 }
21862157}
21872158
2159+ RCT_EXPORT_METHOD (createSendMessage:(NSDictionary *)param
2160+ successCallback:(RCTResponseSenderBlock)successCallback) {
2161+ /* *
2162+ * @param {object} params = {
2163+ * 'type': String, // 'single' / 'group'
2164+ * 'messageType': String, // 'text', 'image', 'voice', 'location', 'file', 'custom'
2165+ * 'groupId': String, // 当 type = group 时,groupId 不能为空
2166+ * 'username': String, // 当 type = single 时,username 不能为空
2167+ * 'appKey': String, // 当 type = single 时,用于指定对象所属应用的 appKey。如果为空,默认为当前应用。
2168+ * 'text': String, // Optional 消息内容
2169+ * 'path': String // Optional 资源路径
2170+ * 'fileName': String, // Optional 文件名
2171+ * 'latitude': Number, // Optional 纬度信息
2172+ * 'longitude': Number, // Optional 经度信息
2173+ * 'scale': Number, // Optional 地图缩放比例
2174+ * 'address': String, // Optional 详细地址信息
2175+ * 'customObject': {'key1': 'value1'} // Optional. Optional 自定义键值对
2176+ * 'extras': Object, // Optional. 自定义键值对 = {'key1': 'value1'}
2177+ * }
2178+ */
2179+ JMSGMessage
21882180
2181+ }
21892182@end
0 commit comments